MySQL Type properties

Source: Internet
Author: User

1, unsigned

When our number types are added to the unsigned, we can store only positive numbers, not negative numbers, and store them in relatively large numbers.

Example:

CREATE Table  intint  UNSIGNED) ENGINE=Innodb;

INSERT test Value (1, 4); # # OK
INSERT test Value (1,-1); # # Error alert [ERR] 1264-out of range value for column ' B ' at row 1

Note: If we use SELECT b-a from Test here;

[ERR] 1690-bigint UNSIGNED value is out of range in ' (' Test '. ' Test '. ' A '-' test '. ' Test '. ' B ')

It is recommended that you do not use the unsiged attribute easily. Generally we use int to meet the size of the value, if not can use bigint

2, Zerofill

is to give the number type 0 before the number of characters. For example a int (4); A=1; The results show that 0001

Example:

ALTER TABLE COLUMN int (4) UNSIGNED Zerofill; # Add a property to the B field with a zero complement

Then SELELCT * from Test;

MySQL Type properties

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.