Mysql Knowledge point 1-1 field type

Source: Internet
Author: User
Tags float double

integral type (int tinyint)
tinyint created by default is a signed
1, control mostly small is controlled by the type, not the latter int (2) to control, he does not mean as long as two bits. (on behalf of 0 fills)
Int (m): M indicates the maximum display width for integer types
2, set the number of digits of the integer if it exceeds the set value to take the maximum value
3. The values in parentheses can be ignored when using integral type

tinyint
Integer data from 0 to 255. The storage size is 1 bytes.

smallint
Integer data from -2^15 (-32,768) to 2^15–1 (32,767). The storage size is 2 bytes.

Int
Integer data (all numbers) from -2^31 (-2,147,483,648) to 2^31–1 (2,147,483,647). The storage size is 4 bytes. The SQL-92 synonymous word for int is integer.
bigint
Integer data (all numbers) from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807). The storage size is 8 bytes.

Floating point and fixed point number
float and double are floating-point numbers, and float is a single-precision double that doubles
Single-and double-precision differences: Double precision can be more than single-precision multiple storage points
Single-precision real number in memory accounted for 32bit significant digit 6~7 bit
A double-precision real number is a 64bit valid digit for a memory unit 15~16 bit
Floats and fixed-point numbers can be represented by using the type-after plus (m,d) method
M: This type shows a total of M numbers
D: Indicates a few digits after the decimal point

Decimal (M,D)
High precision 128bit, floating point type.
The float double is the base type, and decimal is not.
Float valid digits 7-bit, range ±1.5x10e?45 To±3.4x10e38
Double valid digit 15/16-bit, range ±5.0x10 e?324 to±1.7x10e308
Decimal valid digit 28/29-bit, range ±1.0x10e?28 To±7.9x10e28

String
Both char and varchar are similar and can be used to store shorter strings in MySQL
1, char fixed length, the creation of the table when the maximum declared length, can be 0~255. Set a fixed length, no matter how much data you have, it will be the length you set.
2, the varchar value is variable, the length is the value between 0~65535. How many characters are there in the data?
3, char and varchar are truncated to the specified string when they exceed the specified length

Text and blob, the difference between the two
Blob: is the data used to store the binary
Text is the data used to hold the string
Blob and text after a large number of deletions, may cause performance problems, delete later data will leave "empty"
You can use the Optimize table name to reclaim space

Enum type enum
1, enumeration type, is declared when the table is created
2. For 1~255 members, the enumeration type only consumes 1 bytes to store 265~65535 members only using 2 bytes to store. Up to 65,535 members can be stored
3. If the enumerated type is exceeded in the specified value, a ' null ' will be inserted, only a single value can be inserted, and no multiple values can be inserted

Date type (General storage timestamp)

Mysql Knowledge point 1-1 field type

Related Article

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.