TIMESTAMP *A timestamp. TIMESTAMP values are stored as the number of seconds since
the Unix epoch (‘1970-01-01 00:00:00’ UTC). Format: YYYY-MM-DD HH:MI:SS
Note: The supported range is from ‘1970-01-01 00:00:01’ UTC to ‘2038-01-09
03:14:07’ UTC
TIME A time. Format: HH:MI:SS
Note: The supported range is from ‘-838:59:59’ to ‘838:59:59’
YEAR A year in two-digit or four-digit format.
Note: Values allowed in four-digit format: 1901 to 2155. Values allowed in two-
digit format: 70 to 69, representing years from 1970 to 2069
SQL Create Table
CREATE TABLE table_name (
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);
SQL Drop
-- Drop database
DROP DATABASE database_name;
-- Drop table
DROP TABLE table_name;
-- Drop index in MySQL
ALTER TABLE table_name DROP INDEX index_name;
-- Truncate table
TRUNCATE TABLE table_name;
SQL Constraints
1. 约束创建时间
建表时创建
CREATE TABLE table_name (
column_name1 data_type(size) constraint_name,
column_name2 data_type(size) constraint_name,
column_name3 data_type(size) constraint_name,
....
);
建表后追加
非空约束 Not Null