MySQL data type

Source: Internet
Author: User

MySQL base ——— data type Integer type: Depending on the range of values that are stored for the integer value, it can be divided into the following five categories: (1)tinyintoccupies 1 bytes (2)smallintoccupies 2 bytes (3) Mediumint of 3 bytes (4)intoccupies 4 bytes (5)bigint8 bytes The value range of its unsigned and signed integers is determined by the number of bytes per type: single-precision floating-point numbers,float, accounting for 4 bytes of double-precision floating-point numbers,Double, accounting for 8 byte fixed-point number types:decimal(M,D) The number of bytes is M+2, m represents the length of the data, and D represents the length and date type of the data after the decimal point:1. Yearaccounts for 1 bytes in yyyy format2. Time occupies 3 bytes in the format HH:MM:SS3. Date occupies 4 bytes in yyyy format-Mm-DD4.datetimeAccounts for 8 bytes in yyyy format-Mm-DD HH:MM:SS5.timestampAccounts for 4 bytes in yyyy format-Mm-DD HH:MM:SS1. When you make a year type, you can specify the value of year using the following 3 formats (1use a 4-bit string or a numeric representation, ranging from 1901 to 2155, with a string representation that needs to be added ' (2) using a 2-bit string representation, the range is'xx'--' 99 ', where ' 00 '--' 69 ' will be converted into 2000--2069             ' -'--' 99 ' will be converted into 1970--1999(3) using a two-digit number,1--69 will be converted into 2001--2069,70--99 and converted into 1970--1999 .In use '0' with 0 is, two values are not the same, the former is 2000, the latter is 00002The . Date type, when represented, uses the form of a string, or a number, that represents the same value as the number represented in the string representation of the month and the date, but the value of the year can be YYYY, ' YYYY ', yy, ' yy ', depending on type Different means to get different values by current_date or Now () indicates the current time of the system3when the. Time type is represented (1) to'D HH:MM:SS'The string format indicates that the value range of D is 0--34, when inserting data, the value of the hour isD* -+HH (2) in the form of HHMMSS numbers or'HHMMSS'string Format Insert4. When representing a DateTime type, indicating the month or day of the year, you can use either a string format or a number format, which represents the years, which can be expressed in four-bit or two-bit form, using the same value as the value represented by the same as year type. Now () Gets the current time of the system 5when the. Timestamp type is represented, it is displayed in the same manner as the DateTime type, but the range of values is smaller than the DateTime type when using CURRENT_TIMESTAMP, or input null, no input in these three cases, The system will enter the system current time string and the binary type:1.Char(LEN) andvarchar(LEN) represent string types, the values in parentheses after them represent the length of the string, but for char, the amount of storage space for the data is Len bytes, and for varchar types, the amount of data stored is the actual size of their data+1 bytes When the inserted Cahr type value does not reach the length of its identity Len, the system fills with a space2.binary(LEN) andvarbinary(LEN) represents the binary data, which are associated with Charvarcharis similar, but when the value inserted by the binary type does not reach its identified length, the system uses the' /'padded text type: Used to represent large text data, divided into Tinytext,text, Mediumtext,longtext 4, and these four data types represent a larger storage range in turn. BLOB type: A binary data that represents a large amount of data, divided into Tinyblob,blob,mediumblob,longblob, where the storage range of the four data types increases the enum (enum) type: Defined as an enum ('value 1','Value 2',......), the data of the enum type can only be taken from the enumeration list, and each value in the enum list has a sequential number, which is the data number stored in MySQL, not the value of the list set type: The object used to represent the string, its value can be 0 or more, its definition form is set ('value 1','Value 2',......), as with enum, each value in the list has a sequential number, which is the data number stored in MySQL, not the value of the list bit type: Used to represent binary data,bit(LEN)LENThe scope of the -, if the assigned bit (LENdata length is less than Len and will be 0 padded to the left of the data

MySQL data type

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.