MySQL数据类型
MySQL数据库提供了整数类型,浮点类型,定点数类型,位类型, 日期和时间类型,字符串类型
数据类型 | 字节 | 最小值 | 最大值 |
TINYINT | 1 | 有符号 -128,无符号 0 | 有符号127,无符号 255 |
SMALLINT | 2 | 有符号 -32768 无符号 0 | 有符号 32767 无符号 32767 *2+ 1 |
MEDIUMINT | 3 | 有符号 -8388608 无符号 0 | 有符号 8388607无符号 8388607*2 + 1 |
INT | 4 | 有符号 -2147483648 无符号 0 | 有符号 -21474836487无符号 21474836487*2 + 1 |
BIGINT | 8 |
有符号 -9223372036854775808 无符号 0 |
有符号 -9223372036854775807 无符号 922337206854775807 * 2+ 1 |
FLOAT | 4 | +- 1.75494351E-38 | +- -3.402823466E+38 |
DOUBLE | 8 | +- 2.2250738585072014E-308 | +- 1.7976931348623157E+308 |
DEC(M,D) DECIMAL(M,D) | M+2 | 同double | 同double |
BIT | 1~8 | 1 bit | 64 bit |
DATE 年月日 | 4 | 1000-01-01 | 9999-12-31 |
DATETIME 年月日时分秒 | 8 | 1000-01-01 00:00:00.000000 | 9999-12-31 23:59:59.999999 |
TIMESTAMP 当前系统时间 | 4 | 1970-01-01 00:00:01.000000 | 2038-01-19 03:14:07.999999 |
TIME 时分秒 | 3 | -838:59:59.000000 | 838:59:59.000000 |
YEAR 年份 | 1 | 1000 | 9999 |
CHAR(M) | M | ||
VARCHAR(M) | M | ||
TINYTEXT | 0~255 | ||
TEXT | 0~65535 | ||
MEDIUMTEXT | 0~ 16,777,215 | ||
LONGTEXT | 0~4,294,967,295 | ||
BINARY(M) | |||
VARBINARY(M) | |||
TINYBLOB | |||
BLOB | |||
MEDIUMBLOB | |||
LONGBLOB |
这么多的数据类型谁记得住啊,不用记住,几个命令,现场查看:
HELP:
mysql> help Contents; You asked for help about help category: "Contents" For more information, type 'help <item>', where <item> is one of the following categories: Account Management Administration Compound Statements Data Definition Data Manipulation Data Types Functions Functions and Modifiers for Use with GROUP BY Geographic Features Help Metadata Language Structure Plugins Procedures Storage Engines Table Maintenance Transactions User-Defined Functions Utility mysql> help Data Types; You asked for help about help category: "Data Types" For more information, type 'help <item>', where <item> is one of the following topics: AUTO_INCREMENT BIGINT BINARY BIT BLOB BLOB DATA TYPE BOOLEAN CHAR CHAR BYTE DATE DATETIME DEC DECIMAL DOUBLE DOUBLE PRECISION ENUM FLOAT INT INTEGER LONGBLOB LONGTEXT MEDIUMBLOB MEDIUMINT MEDIUMTEXT SET DATA TYPE SMALLINT TEXT TIME TIMESTAMP TINYBLOB TINYINT TINYTEXT VARBINARY VARCHAR YEAR DATA TYPE mysql> help date; -- 哪里不会查哪里 Name: 'DATE' Description: DATE A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATE values in 'YYYY-MM-DD' format, but permits assignment of values to DATE columns using either strings or numbers. URL: http://dev.mysql.com/doc/refman/5.6/en/date-and-time-type-overview.html
可以查看的不止是数据类型,关于MySQL的一切使用帮助。