When should I use UNSIGNED and SIGNED INT in MySQL ? What is better to use or this is just personal prefernce ? Because I\'ve seen it used like this;
id INT
If you know the type of numbers you are going to store, your can choose accordingly. In this case your have 'id' which can never be negative. So you can use unsigned int. Range of signed int: -n/2 to +n/2 Range of unsigned int: 0 to n So you have twice the number of positive numbers available. Choose accordingly.
One thing i would like to add
In a signed int
, which is the default value in mysql
, 1 bit
will be used to represent sign
. -1 for negative and 0 for positive.
So if your application insert only positive value it should better specify unsigned.