最常用的数据库知识收集,SQL语法、表定义、字段类型与取值范围等。
文档:mysql: sql syntax: CREATE TABLE Statement
列类型定义,mysql: sql syntax: Data Types,mysql 5.7 支持以下类型:
整数类型:
Type Storage Minimum Value Minimum Value Maximum Value Maximum Value
Bytes Signed Unsigned Signed Unsigned
TINYINT 1 -128 0 127 255
SMALLINT 2 -32768 0 32767 65535
MEDIUMINT 3 -8388608 0 8388607 16777215
INT 4 -2147483648 0 2147483647 4294967295
BIGINT 8 -2^63 0 2^63-1 2^64-1
精确数值,精确的十进制数:
salary DECIMAL(5,2) # 数值位数是 5,精确位数是 2,取值范围为:-999.99 ~ 999.99
浮点数,非精确值:
FLOAT
DOUBLE
位值:
BIT(M) # M 的范围是 1~64
Data Type “Zero” Value
DATE '0000-00-00'
TIME '00:00:00'
DATETIME '0000-00-00 00:00:00'
TIMESTAMP '0000-00-00 00:00:00'
YEAR 0000
DataType
CHAR
VARCHAR
BINARY
VARBINARY
BLOB
TEXT
ENUM
SET
GEOMETRY
POINT
LINESTRING
POLYGON
MULTIPOINT
MULTILINESTRING
MULTIPOLYGON
GEOMETRYCOLLECTION
mysql> CREATE TABLE t1 (jdoc JSON);
Query OK, 0 rows affected (0.20 sec)
mysql> INSERT INTO t1 VALUES('{"key1": "value1", "key2": "value2"}');
Query OK, 1 row affected (0.01 sec)