book表的属性如下: book_id, int book_name, varchar(100) authors varchar(100) info varchar(100) comments varchar(100) year_publication datetime 根据如下要求编写SQL代码: 1、创建 book 表,同时为 book_name, info 属性显示创建联合索引mul_bname_info,验证索引是否创建成功 2、修改 book 表,并为 comments 属性创建普通索引idx_cmt,为 book_name 属性创建唯一索引uk_idx_bname 3、删除 book 表 的联合索引mul_bname_info
时间: 2024-01-26 12:02:18 浏览: 9
1. 创建 book 表并创建联合索引mul_bname_info:
```
CREATE TABLE book (
book_id INT PRIMARY KEY,
book_name VARCHAR(100),
authors VARCHAR(100),
info VARCHAR(100),
comments VARCHAR(100),
year_publication DATETIME,
INDEX mul_bname_info (book_name, info)
);
```
验证索引是否创建成功:
```
SHOW INDEX FROM book;
```
2. 修改 book 表,并为 comments 属性创建普通索引idx_cmt,为 book_name 属性创建唯一索引uk_idx_bname:
```
ALTER TABLE book
ADD INDEX idx_cmt (comments),
ADD UNIQUE INDEX uk_idx_bname (book_name);
```
3. 删除 book 表的联合索引mul_bname_info:
```
ALTER TABLE book
DROP INDEX mul_bname_info;
```
阅读全文