1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > MySQL创建视图yggl_建立索引和创建视图(结合YGGL.sql)

MySQL创建视图yggl_建立索引和创建视图(结合YGGL.sql)

时间:2022-02-21 17:06:59

相关推荐

MySQL创建视图yggl_建立索引和创建视图(结合YGGL.sql)

一.请按要求对YGGL库建立相关索引

(1)使用create index 语句创建索引

1.对employees表中的员工部门号创建普通索引depart_ind.

mysql> create index depart_ind

-> on employees(员工编号);

Query OK, 12 rows affected (0.04 sec)

Records: 12 Duplicates: 0 Warnings: 0

2.对employees表中的姓名和地址创建复合索引 ad_ind.

mysql>create index ad_ind on employees(姓名,地址);

Query OK, 12 rows affected (0.00 sec)

Records: 12 Duplicates: 0 Warnings: 0

3.对 departments表中的部门名称创建唯一索引.

mysql> create uniqueindex department_index

-> on departments(部门名称);

Query OK, 5 rows affected (0.04 sec)

Records: 5 Duplicates: 0 Warnings: 0

(2) 使用altertable语句添加索引

1.对employees表中的出生日期添加一个唯一索引date_ind,姓名和性别添加一个复合索引na_ind.

mysql> alter table employeesadd unique index date_ind(出生日期),

->add index na_ind(姓名,性别);

Query OK, 12 rows affected (0.03 sec)

<

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。