MySQL - DDL语句
删除主键
- 首先,要删除自动递增。
alter table 表名 modify 列名 类型;
- 然后再删除主键约束。
alter table 表名 drop primary key;
创建表时添加约束
- 创建 depts 表包含 department_id 该列为主键且自动增长,department_name 列不 允许重复,location_id 列不允含有空值。
create table depts(department_id int primary key auto_increment,department_name varchar(30) unique,location_id int not null)