大家好,又见面了,我是你们的朋友全栈君。
1、创建表的同时 指定
create table t1(
id int not null,
name char(30) not null,
unique index UniqIdx(id)
)
2、在已经存在的表创建索引
使用ALTER TABLE 语句创建索引
1.执行语句
alter table book add index BkName(bookname(30))
2.show index 查看表中索引
show index from book
可以看到新增了一个索引
创建唯一索引:
alter table book add index UniqiIdx(bookId)
使用CREATE TABLE 语句创建索引
创建普通索引:
create index BkNameIdx on book(bookname)
创建唯一索引:
create unique index UniqIdx on book(bookId)
使用ALTER TABLE 语句删除索引
alter table 表名 drop index 索引名
使用DROP INDEX 语句删除索引
drop index 索引名 on 表名
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/196263.html原文链接:https://javaforall.cn