MySQL type properties unsigned and Zerofill

Source: Internet
Author: User

1. Unsigned is the unsigned number type.

The type range of int is -2147483648~2147483647, and the type range of int unsigned is 0~4294967295

Unsigned can also have negative effects, such as:

CREATE TABLE T (a int unsigned,b int unsigned)

INSERT into T SELECT

What will be the result of SElECT A-B from T, will it be-1, the answer is not sure, in the Mac system will be an error,

The result in the Linux system is 4294967295, so try not to use unsigned, but this is not a bug, you can refer to the MySQL Technical insider explanation

How to get -1 value, as long as the Sql_mode this parameter setting can be

SET sql_mode= ' no_unsigned_subtraction ';

2. Zerofill, if the width is less than the set value is automatically filled 0

ALTER TABLE T Change a A int (4) unsigned zerofill;

Select a from T

Result is 0001

MySQL type properties unsigned and Zerofill

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.