SQL练习37:对first_name创建唯一索引uniq_idx_firstname,对last_name创建普通索引idx_lastname

SQL练习37:对first_name创建唯一索引uniq_idx_firstname,对last_name创建普通索引idx_lastname

题目链接:牛客网

题目描述
针对如下表actor结构创建索引:
(注:在 SQLite中,除了重命名表和在已有的表中添加列,ALTER TABLE命令不支持其他操作,
mysql支持ALTER TABLE创建索引)。

CREATE TABLE actor  (
   actor_id  smallint(5)  NOT NULL PRIMARY KEY,
   first_name  varchar(45) NOT NULL,
   last_name  varchar(45) NOT NULL,
   last_update  datetime NOT NULL);

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);

猜你喜欢

转载自blog.csdn.net/qq_43965708/article/details/113725789