数据库SQL实战(牛客网):对first_name创建唯一索引uniq_idx_firstname

针对如下表actor结构创建索引:
CREATE TABLE IF NOT EXISTS actor (
actor_id smallint(5) NOT NULL PRIMARY KEY,
first_name varchar(45) NOT NULL,
last_name varchar(45) NOT NULL,
last_update timestamp NOT NULL DEFAULT (datetime(‘now’,‘localtime’)))
对first_name创建唯一索引uniq_idx_firstname,对last_name创建普通索引idx_lastname

第一句是添加唯一索引,第二句是添加普通索引

create unique index uniq_idx_firstname on actor(first_name);
create index idx_lastname on actor(last_name);
发布了352 篇原创文章 · 获赞 73 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43777983/article/details/104976435
今日推荐