To facilitate the use of code written for SQL implementations from other vendors, MySQL maps data types as shown in the following table. 为了方便使用为其他供应商的SQL实现编写的代码,MySQL映射了如下表所示的数据类型。These mappings make it easier to import table definitions from other database systems into MySQL.这些映射使得将表定义从其他数据库系统导入MySQL更加容易。
MySQL | |
---|---|
BOOL | TINYINT |
BOOLEAN | TINYINT |
CHARACTER VARYING( | VARCHAR( |
FIXED | DECIMAL |
FLOAT4 | FLOAT |
FLOAT8 | DOUBLE |
INT1 | TINYINT |
INT2 | SMALLINT |
INT3 | MEDIUMINT |
INT4 | INT |
INT8 | BIGINT |
LONG VARBINARY | MEDIUMBLOB |
LONG VARCHAR | MEDIUMTEXT |
LONG | MEDIUMTEXT |
MIDDLEINT | MEDIUMINT |
NUMERIC | DECIMAL |
Data type mapping occurs at table creation time, after which the original type specifications are discarded. 数据类型映射发生在表创建时,之后原始类型规范将被丢弃。If you create a table with types used by other vendors and then issue a 如果您使用其他供应商使用的类型创建一个表,然后发出DESCRIBE
statement, MySQL reports the table structure using the equivalent MySQL types. tbl_name
DESCRIBE tbl_name
语句,MySQL将使用等效的MySQL类型报告表结构。For example:例如:
mysql>CREATE TABLE t (a BOOL, b FLOAT8, c LONG VARCHAR, d NUMERIC);
Query OK, 0 rows affected (0.00 sec) mysql>DESCRIBE t;
+-------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------+------+-----+---------+-------+ | a | tinyint(1) | YES | | NULL | | | b | double | YES | | NULL | | | c | mediumtext | YES | | NULL | | | d | decimal(10,0) | YES | | NULL | | +-------+---------------+------+-----+---------+-------+ 4 rows in set (0.01 sec)