2017年9月13日 12:55
索引类型:
index索引:
在已有表中创建index索引:
create index 索引名 on 表名(字段名);
删除索引:
drop index 索引名 on 表名;
查看:
show index from 表名;
主键:
建表时指定主键
primary key(字段名)
在已有表中设置主键:
alter table 表名 add primary key(字段名);
移除:
alter table 表名 drop primary key;
unique唯一索引
在已有表中设置unique
create unique index xxx on 表名(字段名);
foreign外键
用法:
删除外键:
alter table 表名 drop foreign key 约束名;