not null :非空
default:默认值;
unique :唯一值;
primary key :主键;
foreign key :外键;
check :检查条件;
后面不需要带参数的约束:not null
后面需要带参数的约束(关键词后面加括号): primary key 、foreign key、check、unique
后面不需要加括号的约束:default
CREATE TABLE test1(
uid INT NOT NULL ,
`name` VARCHAR(50) ,
`password` VARCHAR(20) NOT NULL DEFAULT '0',
class_id INT NOT NULL,
UNIQUE(uid),
PRIMARY KEY(uid),
FOREIGN KEY(class_id) REFERENCES class_table(class_id),
CHECK (class_id < 1000)
);