系列文章目录
前言
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到网站,这篇文章男女通用,看懂了就去分享给你的码吧。
描述
针对如下表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
sql语句:
alter table actor add unique uniq_idx_firstname(first_name);
alter table actor add index idx_lastname(last_name);
sqlite语句:
create unique index uniq_idx_firstname on actor(first_name);
create index idx_lastname on actor(last_name);