数据库SQL实战题:对first_name创建唯一索引uniq_idx_firstname(教程)
程序员文章站
2022-07-05 22:46:52
针对如下表actor结构创建索引:
CREATE TABLE IF NOT EXISTS actor (
actor_id smallint(5) NOT NULL PRIMA...
针对如下表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
【注意actor和()间不能有空格!】
即
create index idx_lastname on actor(last_name); create index idx_lastname on actor (last_name);
//创建唯一索引 create unique index uniq_idx_firstname on actor(first_name); //创建普通索引 create index idx_lastname on actor(last_name);