types - What does `unsigned` in MySQL mean and when to use it?

ID : 10449

viewed : 59

Tags : mysqltypesmysql

Top 5 Answer for types - What does `unsigned` in MySQL mean and when to use it?

vote vote


MySQL says:

All integer types can have an optional (nonstandard) attribute UNSIGNED. Unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column. For example, if an INT column is UNSIGNED, the size of the column's range is the same but its endpoints shift from -2147483648 and 2147483647 up to 0 and 4294967295.

When do I use it ?

Ask yourself this question: Will this field ever contain a negative value?
If the answer is no, then you want an UNSIGNED data type.

A common mistake is to use a primary key that is an auto-increment INT starting at zero, yet the type is SIGNED, in that case you’ll never touch any of the negative numbers and you are reducing the range of possible id's to half.

vote vote


Or, failing mutt:

gzip -c mysqldbbackup.sql | uuencode mysqldbbackup.sql.gz  | mail -s "MySQL DB" backup@email.com 
vote vote


Depending on your version of linux it may be called mail. To quote @David above:

mail -s "Backup" -a mysqldbbackup.sql backup@email.com < message.txt 

or also:

cat message.txt | mail -s "Backup" -a mysqldbbackup.sql backup@email.com  
vote vote


From looking at man mailx, the mailx program does not have an option for attaching a file. You could use another program such as mutt.

echo "This is the message body" | mutt -a file.to.attach -s "subject of message" recipient@domain.com 

Command line options for mutt can be shown with mutt -h.

vote vote


I use SendEmail, which was created for this scenario. It's packaged for Ubuntu so I assume it's available

sendemail -f sender@some.where -t receiver@some.place -m "Here are your files!" -a file1.jpg file2.zip


Top 3 video Explaining types - What does `unsigned` in MySQL mean and when to use it?