一.请按要求对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)
<