DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   MySQL (http://www.daniweb.com/forums/forum126.html)
-   -   use of mysql unsigned ? (http://www.daniweb.com/forums/thread38563.html)

nike123 Jan 23rd, 2006 10:49 am
use of mysql unsigned ?
 
IWhat exactly is the "unsigned" use for in sql and when should i consider using it?

Troy Mar 8th, 2006 12:30 am
Re: use of mysql unsigned ?
 
The best I can gather from the documentation is that "signed" or "unsigned" refers to the plus or minus sign a person would traditionally use to indicate a positive or negative value. So an UNSIGNED numeric value can never be negative.

Therefore, if you have a column that you want to contain a numeric value, but never hold a negative value, I guess you could apply the UNSIGNED modifier to the data type.

http://dev.mysql.com/doc/refman/5.0/...-overview.html

paradox814 Apr 15th, 2006 1:37 am
Re: use of mysql unsigned ?
 
the biggest difference is an unsigned number cannot be negative (just as stated above)

but the benefit of usign an unsigned number is that you can have a greater range of positive numbers.

Tinyint: The signed range is -128 to 127. The unsigned range is 0 to 255.
Mediumint: The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.
Bigint: The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.

you get the point from there, a great use of unsigned numbers is for any column that has an auto_increment flag on it, since it will never be negative


All times are GMT -4. The time now is 12:32 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC