提交 bb2e9bf8 编写于 作者: M Mars Liu

drop index

上级 a9d61d98
{
"node_id": "mysql-bf629829370d405cbfcd5aa83adb536a",
"keywords": [],
"keywords": ["index", "index"],
"children": [],
"export": [],
"export": [
"index.json"
],
"keywords_must": [
["mysql", "索引", "入门"]
[
"mysql",
"索引",
"入门"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "index.md",
"notebook_enable": false,
"exercise_id": "ac49bba4d8fc428b90c8773b07b6ec65"
}
\ No newline at end of file
# 索引
关于 MySQL 的索引,一下说法正确的是:
1. 索引可以指定不同的格式,以满足不同的性能需求
2. 索引可以伴有唯一约束
3. 主键会自动包含聚集索引
4. 聚集索引只能应用于自增字段
5. 索引可以基于一个或多个字段
6. 可以创建函数或表达式索引
7. MySQL 支持全文索引(Full Text Index)
## 答案
```
1, 2, 3, 5, 6, 7
```
## 选项
### A
全部都对
### B
全部都错
### C
```
1, 2, 3, 4
```
### D
```
4, 5, 6, 7
```
### E
```
2, 4, 6, 8
```
\ No newline at end of file
{
"node_id": "mysql-fe65d5c615ad40f8ac056cc654f2d788",
"keywords": [],
"keywords": ["create index", "创建索引"],
"children": [],
"export": [],
"export": [
"create_index.json"
],
"keywords_must": [
["mysql", "创建", "索引"]
[
"mysql",
"创建",
"索引"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "create_index.md",
"notebook_enable": false,
"exercise_id": "6b84238a23d24623a32c416016075701"
}
\ No newline at end of file
# 创建索引
Joe 想给 Goods 表
```mysql
create table goods(
id int primary key auto_increment,
category_id int,
name varchar(256),
price decimal(12, 4),
stock int,
upper_time timestamp
)
```
的 category_id (类别)字段创建索引,便于根据类别查询商品。应该执行下面哪个语句?
*注意* 一个类别会包含多种商品。
## 答案
```mysql
create index idx_goods_category on goods(category_id);
```
## 选项
### A
```mysql
create unique index idx_goods_category on goods(category_id);
```
### B
```mysql
create index idx_goods_category on goods(category_id);
```
### C
```mysql
alter table goods add unique index (category_id);
```
\ No newline at end of file
{
"node_id": "mysql-85ba0df78d754b00b30aa8e74ad35d06",
"keywords": [],
"keywords": [
"删除索引",
"drop index"
],
"children": [],
"export": [],
"export": [
"drop_index.json"
],
"keywords_must": [
["mysql", "删除", "索引"]
[
"mysql",
"删除",
"索引"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
\ No newline at end of file
{
"type": "code_options",
"author": null,
"source": "drop_index.md",
"notebook_enable": false,
"exercise_id": "f786df4790e0407b91348a0fad24220f"
}
\ No newline at end of file
# 删除索引
Joe 想要删除创建在 goods 表创建的索引,但是他已经忘了这个索引的名字,那么他应该怎么做?
## 答案
执行
```mysql
show index from goods;
```
查看 goods 表的索引(假设查到是 idx_goods_category),然后执行
```mysql
alter table goods drop index idx_goods_category;
```
## 选项
### A
执行
```mysql
show index from goods;
```
查看 goods 表的索引(假设查到是 idx_goods_category),然后执行
```mysql
alter table goods delete index idx_goods_category;
```
### B
执行
```mysql
show index from goods;
```
查看 goods 表的索引(假设查到是 idx_goods_category),然后执行
```mysql
alter table goods remove index idx_goods_category;
```
### C
执行
```mysql
show index from goods;
```
查看 goods 表的索引(假设查到是 idx_goods_category),然后执行
```mysql
alter table goods drop idx_goods_category;
```
{
"type": "code_options",
"author": null,
"author": "Mars",
"source": "in_column.md",
"notebook_enable": false,
"exercise_id": "464fd8f686284280afbee9424ed4ae65"
......
......@@ -1098,7 +1098,10 @@
{
"索引入门": {
"node_id": "mysql-bf629829370d405cbfcd5aa83adb536a",
"keywords": [],
"keywords": [
"index",
"index"
],
"children": [],
"keywords_must": [
[
......@@ -1108,13 +1111,16 @@
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
"创建索引": {
"node_id": "mysql-fe65d5c615ad40f8ac056cc654f2d788",
"keywords": [],
"keywords": [
"create index",
"创建索引"
],
"children": [],
"keywords_must": [
[
......@@ -1124,13 +1130,16 @@
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
"删除索引": {
"node_id": "mysql-85ba0df78d754b00b30aa8e74ad35d06",
"keywords": [],
"keywords": [
"删除索引",
"drop index"
],
"children": [],
"keywords_must": [
[
......@@ -1140,7 +1149,7 @@
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
}
],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册