mysql--Data types

Source: Internet
Author: User

Classification of data types
Numeric (integer, fractional), character, date, decimals divided into fixed-point and floating-point numbers.
First, the integral type

Note: ① If unsigned is not set, the default is signed, and if set to unsigned, the unsigned keyword needs to be added.
② if the inserted value exceeds the range of the integer type, the out of range exception is reported and the threshold value is inserted.
③ If you do not set the length, there will be a default length.
The ④ length represents the maximum width shown, if not enough for 0 on the left side, but must be paired with Zerofill

Insert threshold Value:

Default length:

To set the unsigned type:

Setting the 0 Fill will automatically add unsigned:

0 Fill in case:

Second, decimal

Float (m,d) double (m,d) and Dec (m,d) Decimal (m,d)
Note:
①m: Range is integral part + fractional part
②d: Refers to a small number of parts
③ if the range is exceeded, the threshold value is inserted
④m and D can be omitted, if it is dec, the default value 10,d default is 0
⑤float and double, which determines the precision based on the precision of the inserted numeric value
The precision of ⑥ fixed-point type is higher, if the precision of inserting numeric value is higher, such as currency arithmetic, then consider using

Default value for Dec:

Default length and precision:

Three, character type
Short text:
char (m), varchar (m)
Binary and varbinary are used to hold shorter text
Enum is used to hold enum types
Set is used to save the collection
Long text:
Text blob (large binary)

The difference between char and varchar:


Iv. Type of date

Note:
①date only save date, time only, year value save years
②datetime Save Date + time, timestamp save date + time

mysql--Data types

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.