MySQL official documentation: http://dev.mysql.com/doc/refman/5.1/zh/data-types.html
The detailed descriptions below are not necessarily accurate and incomplete. Please include more or give your suggestions. I 'd like to hear from you.
Numeric column types: int, bigint, smallint, and tinyint
The number column type is used to store various numeric data, such as price, age, or quantity. There are two types of numeric columns: integer and floating point. All numeric column types can have two options: unsigned and zerofill. Unsigned Columns cannot have negative numbers. If zerofill is selected, zero is added to the values. The following figure shows the available numeric column types in MySQL.
• Tinyint -- a tiny integer that supports-128 to 127 (Signed), 0 to 255 (unsigned), and needs to be stored in 1 byte
• Bit -- same as tinyint (1)
• Bool -- same as tinyint (1)
• Smallint -- a small integer that supports-32768 to 32767 (Signed), 0 to 65535 (unsigned), requiring 2 bytes to store mediumint -- a medium integer, supports-8388608 to 8388607 (Signed), 0 to 16777215 (unsigned), and three bytes are required for storage.
• Int -- an integer that supports-2147493648 to 2147493647 (Signed), 0 to 4294967295 (unsigned), and needs to be stored in 4 bytes
• Integer -- same as int
• Bigint -- a large integer that supports-9223372036854775808 to 9223372036854775807 (Signed), 0 to 18446744073709551615 (unsigned), and requires 8 bytes of Storage
• Float (precision)-a floating point number. Precision <= 24 is used for single-precision floating point; precision is between 25 and 53, and is used for precision Floating Point. The float (x) has the same range as the float and double types of the phase sequence, but the display size and decimal places are not defined. Before mysql3.23, this is not a real floating point value and always has two decimal places. All the calculations in MySQL use dual precision, which may cause unexpected problems.
• Float-a small menu precision floating point number. Supports-3.402823466e + 38 to-1.175494351e-38,0 and 1.175494351e-38 to 3.402823466e + 38, which requires 4 bytes of storage. If it is unsigned, the range of positive numbers remains unchanged, but negative numbers are not allowed.
• Double-a double-precision floating point number. Supports-1.7976931348623157e + 308 to-2.225074255072014e-308,0 and 2.225071095072014e-308 to 1.7976931348623157e + 308. If it is float, unsigned will not change the positive number range, but the negative number is not allowed.
• Double precision -- same as double
• Real -- same as double
• Decimal -- stores a number as a string, and each character occupies one byte
• Dec -- same as decimal
• Numeric -- same as decimal
String column types: Char, varchar, and nvarchar
The string column type is used to store character data of any type, such as name, address, or newspaper. Below are available string column types in MySQL
• Char -- character. A string of fixed length. Fill in spaces on the right to reach the specified length. It can be 0 to 155 characters in length. When you search for a value, spaces with the suffix will be deleted.
• Varchar-a variable-length character. A variable-length string with the suffix space removed when storing the value. Supports from 0 to 255 characters
• Tinyblob-tiny binary objects. 255 characters are supported. Storage with a length of more than 1 byte is required. Like tinytext, the search is case sensitive. (0.25kb)
• Tinytext -- supports 255 characters. The length must be + 1 byte. Like tinyblob, The Case sensitivity is ignored during search. (0.25kb)
• Blob -- binary object. 65535 characters are supported. Storage with a length of + 2 bytes is required. (64 KB)
• Text -- supports 65535 characters. Requires Length + 2 bytes of storage. (64 KB)
• Mediumblob-a medium-sized binary object. 16777215 characters are supported. Storage with a length of + 3 bytes is required. (16 m)
• Mediumtext-supports 16777215 characters. Storage with a length of + 3 bytes is required. (16 m)
• Longblob -- a large binary object. 4294967295 characters are supported. Storage with a length of + 4 bytes is required. (4G)
• Longtext-supports 4294967295 characters. Storage with a length of + 4 bytes is required. (4G)
• Enum -- enumeration. There can be only one specified value, that is, null or "", with a maximum of 65535 values
• Set -- a set. There can be 0 to 64 values, all from the specified list.
Date and Time column types
The date and time column types are used to process time data. data such as the date of the current day or the date of birth can be stored. Format: Y indicates year, M (before m) indicates month, d Indicates day, h indicates hour, M (after M) indicates minute, s indicates second. The following are available date and time column types in MySQL:
• Datetime -- format: 'yyyy-MM-DD hh: mm: ss', range: '2017-01-01 00:00:00 'to '2017-12-31 23:59:59'
• Date -- format: 'yyyy-MM-DD ', range: '2017-01-01' to '2017-12-31'
• Timestamp -- format: 'yyyymmddhhmms', 'yymmddhhmms', 'yyyymmdd', and 'yymmdd'; range: '2017-01-01 00:00:00 'to '2017-01-01 00:00:00'
• Time -- format: 'hh: mm: ss'
• Year -- format: 'yyyy, range: '000000' to '000000'
MySQL has three types of columns: Numbers, strings, and dates.
MySQL official documentation: http://dev.mysql.com/doc/refman/5.1/zh/data-types.html
The detailed descriptions below are not necessarily accurate and incomplete. Please include more or give your suggestions. I 'd like to hear from you.
Numeric column types: int, bigint, smallint, and tinyint
The number column type is used to store various numeric data, such as price, age, or quantity. There are two types of numeric columns: integer and floating point. All numeric column types can have two options: unsigned and zerofill. Unsigned Columns cannot have negative numbers. If zerofill is selected, zero is added to the values. The following figure shows the available numeric column types in MySQL.
• Tinyint -- a tiny integer that supports-128 to 127 (Signed), 0 to 255 (unsigned), and needs to be stored in 1 byte
• Bit -- same as tinyint (1)
• Bool -- same as tinyint (1)
• Smallint -- a small integer that supports-32768 to 32767 (Signed), 0 to 65535 (unsigned), requiring 2 bytes to store mediumint -- a medium integer, supports-8388608 to 8388607 (Signed), 0 to 16777215 (unsigned), and three bytes are required for storage.
• Int -- an integer that supports-2147493648 to 2147493647 (Signed), 0 to 4294967295 (unsigned), and needs to be stored in 4 bytes
• Integer -- same as int
• Bigint -- a large integer that supports-9223372036854775808 to 9223372036854775807 (Signed), 0 to 18446744073709551615 (unsigned), and requires 8 bytes of Storage
• Float (precision)-a floating point number. Precision <= 24 is used for single-precision floating point; precision is between 25 and 53, and is used for precision Floating Point. The float (x) has the same range as the float and double types of the phase sequence, but the display size and decimal places are not defined. Before mysql3.23, this is not a real floating point value and always has two decimal places. All the calculations in MySQL use dual precision, which may cause unexpected problems.
• Float-a small menu precision floating point number. Supports-3.402823466e + 38 to-1.175494351e-38,0 and 1.175494351e-38 to 3.402823466e + 38, which requires 4 bytes of storage. If it is unsigned, the range of positive numbers remains unchanged, but negative numbers are not allowed.
• Double-a double-precision floating point number. Supports-1.7976931348623157e + 308 to-2.225074255072014e-308,0 and 2.225071095072014e-308 to 1.7976931348623157e + 308. If it is float, unsigned will not change the positive number range, but the negative number is not allowed.
• Double precision -- same as double
• Real -- same as double
• Decimal -- stores a number as a string, and each character occupies one byte
• Dec -- same as decimal
• Numeric -- same as decimal
String column types: Char, varchar, and nvarchar
The string column type is used to store character data of any type, such as name, address, or newspaper. Below are available string column types in MySQL
• Char -- character. A string of fixed length. Fill in spaces on the right to reach the specified length. It can be 0 to 155 characters in length. When you search for a value, spaces with the suffix will be deleted.
• Varchar-a variable-length character. A variable-length string with the suffix space removed when storing the value. Supports from 0 to 255 characters
• Tinyblob-tiny binary objects. 255 characters are supported. Storage with a length of more than 1 byte is required. Like tinytext, the search is case sensitive. (0.25kb)
• Tinytext -- supports 255 characters. The length must be + 1 byte. Like tinyblob, The Case sensitivity is ignored during search. (0.25kb)
• Blob -- binary object. 65535 characters are supported. Storage with a length of + 2 bytes is required. (64 KB)
• Text -- supports 65535 characters. Requires Length + 2 bytes of storage. (64 KB)
• Mediumblob-a medium-sized binary object. 16777215 characters are supported. Storage with a length of + 3 bytes is required. (16 m)
• Mediumtext-supports 16777215 characters. Storage with a length of + 3 bytes is required. (16 m)
• Longblob -- a large binary object. 4294967295 characters are supported. Storage with a length of + 4 bytes is required. (4G)
• Longtext-supports 4294967295 characters. Storage with a length of + 4 bytes is required. (4G)
• Enum -- enumeration. There can be only one specified value, that is, null or "", with a maximum of 65535 values
• Set -- a set. There can be 0 to 64 values, all from the specified list.
Date and Time column types
The date and time column types are used to process time data. data such as the date of the current day or the date of birth can be stored. Format: Y indicates year, M (before m) indicates month, d Indicates day, h indicates hour, M (after M) indicates minute, s indicates second. The following are available date and time column types in MySQL:
• Datetime -- format: 'yyyy-MM-DD hh: mm: ss', range: '2017-01-01 00:00:00 'to '2017-12-31 23:59:59'
• Date -- format: 'yyyy-MM-DD ', range: '2017-01-01' to '2017-12-31'
• Timestamp -- format: 'yyyymmddhhmms', 'yymmddhhmms', 'yyyymmdd', and 'yymmdd'; range: '2017-01-01 00:00:00 'to '2017-01-01 00:00:00'
• Time -- format: 'hh: mm: ss'
• Year -- format: 'yyyy, range: '000000' to '000000'