约束
主键约束 能够唯一确定一张表中的一条记录,也就是我们通过给某一字段添加约束,就可以使得该字段不重复且不为空 mysql> use test Database changed mysql> create table user( -> id int primary key, -> name varchar(20) -> ); Query OK, 0 rows affected (0.14 sec) mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | pet | | user | +----------------+ 2 rows in set (0.00 sec) mysql> describe user; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | name | varchar(20) | YES | | NULL | | +-----