提交 9d06ce74 编写于 作者: M Mars Liu

mistakes fixed

上级 5568288c
......@@ -3,8 +3,9 @@
Joe 打算写一个查询,根据员工表
```mysql
create table employee(
id int primary key auto_increment,
create table employee
(
id int primary key auto_increment,
dept varchar(256),
name varchar(256),
post varchar(16)
......@@ -16,7 +17,40 @@ create table employee(
## 答案
```mysql
select distinct(dept) as dept,
(select count(*) from employee as i where i.dept=o.dept) as emp
select distinct(dept) as dept,
(select count(*)
from employee as i
where i.dept = o.dept) as emp
from employee as o;
```
## 选项
### A
```mysql
select distinct(dept) as dept,
(select count(*)
from employee as i) as emp
from employee as o;
```
### B
```mysql
select distinct(dept) as dept,
(select count(*)
from employee
where dept = dept) as emp
from employee
```
### C
```mysql
select dept as dept,
(select count(*)
from employee as i
where i.dept = o.dept) as emp
from employee as o
```
\ No newline at end of file
#
\ No newline at end of file
# 查看用户权限
Joe 想要查看 Fred 的 MySQL 账户 `'fred'@'%'` 的权限,他应该怎么做?
## 答案
```mysql
show grants for fred;
```
## 选项
### A
```mysql
select grants from fred;
```
### B
```mysql
show privileges for fred;
```
### B
```mysql
show privileges from fred;
```
# 修改口令
Fred 有一个 `'fred'@'%'` 账户,但是他忘了密码,需要 Joe 帮他修改一个新口令,
Joe 准备将这个口令初始化为 'goods123fred',并设置为登录后修改新口令。
Joe 应该怎么操作
Fred 有一个名为 `'fred'@'%'` 的 MySQL 账户,但是他忘了密码,需要 Joe 帮他修改一个新口令,
Joe 准备将这个账户的口令初始化为 `goods123fred`
并设置为登录后修改新口令。他应该怎么做
## 答案
## 答案
```mysql
alter user 'fred'@'%' identified by 'goods123fred' password expire;
......
{
"node_id": "mysql-9f8881b9f30544149327af68e3007603",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-ba3fc0140b5842bb949c591d059e3269",
"keywords": ["full text index", "fti"],
"keywords": [
"full text index",
"fti"
],
"children": [],
"export": [],
"export": [
"full_text_index.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
......
{
"type": "code_options",
"author": "ccat",
"source": "full_text_index.md",
"notebook_enable": false,
"exercise_id": "42e674c6764a40eb9124b6bffb6222fa"
}
\ No newline at end of file
# 全文索引
Shop 表的部分字段如下:
```mysql
create table shop (
id int primary key auto_increment,
description varchar(8000)
-- ...
)
```
现在 Joe 要给 description 字段加上全文索引,他应该怎么做?
## 答案
```mysql
alter table shop add fulltext(description);
```
## 选项
### A
```mysql
alter table shop add index fulltext(description);
```
### B
```mysql
alter table shop create fulltext(description);
```
### C
```mysql
alter table shop alter description add fulltext(description);
```
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "mysql-c57e1195b0914cd38798ce029156ec87",
"keywords": [],
"children": [],
"export": [],
"export": [
"invisible.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
......
{
"type": "code_options",
"author": "ccat",
"source": "invisible.md",
"notebook_enable": false,
"exercise_id": "07a6f3f1f98d49249a2ba14fae5a4cad"
}
\ No newline at end of file
# 隐藏索引
Shop 表的部分字段如下:
```mysql
create table shop (
id int primary key auto_increment,
description varchar(8000),
fulltext (description)
-- ...
)
```
已知 description 字段上的全文索引名为 description。因为这个表已经很大,Joe
想要删掉这个索引,但是他不确定是否有程序还在使用它,
Joe 应该怎么做?
## 答案
先执行
```mysql
alter table shop alter index description invisible ;
```
将索引隐藏,观察确认没有影响后再执行
```mysql
alter table shop drop index description;
```
删除。
## 选项
### A
先备份 shop 表,然后执行
```mysql
alter table shop drop index description;
```
删除,有问题的话从备份文件恢复。
### B
备份 shop ,然后删除重建,重建时去掉 description 相关的索引逻辑。
### C
先执行
```mysql
alter table shop alter index description invisible ;
```
将索引隐藏,确认后再执行
```mysql
alter table shop alter index description visible ;
```
恢复索引可见。
\ No newline at end of file
{
"node_id": "mysql-cc8d1f5fa1e74b6bac93488149c5845f",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-387801d5a5124f78a7bf3d68f3618a57",
"keywords": ["like"],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
......@@ -2,8 +2,10 @@
"node_id": "mysql-2f417818ad3449268396157cbb9d4d9c",
"keywords": [],
"children": [],
"export": [],
"export": [
"geo_index.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 2
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "geo_index.md",
"notebook_enable": false,
"exercise_id": "4ff8589a210e4ed2bf20aba25082e04a"
}
\ No newline at end of file
# 几何索引
Goods 数据库中有一个 shop 表,其中包含如下字段:
```mysql
create table shop (
id int primary key auto_increment,
location GEOMETRY
-- ...
)
```
现在 Joe 要给 location 字段加上几何索引,他应该怎么做?
## 答案
```mysql
alter table shop modify location GEOMETRY not null;
alter table shop add INDEX geo_index(location);
```
## 选项
### A
```mysql
alter table shop add INDEX geo_index(location);
```
### B
```mysql
alter table shop add INDEX location;
```
### C
```mysql
alter table shop modify location GEOMETRY not null;
alter table shop add INDEX location;
```
### D
```mysql
alter table shop modify location GEOMETRY not null;
alter table shop add INDEX location;
```
......@@ -1349,7 +1349,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
......@@ -1359,7 +1359,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
......@@ -1369,7 +1369,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
......@@ -1381,7 +1381,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
......@@ -1391,7 +1391,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
......@@ -1401,7 +1401,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
......@@ -1414,7 +1414,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 2
}
}
],
......@@ -1522,38 +1522,6 @@
"group": 0
}
},
{
"NULL": {
"node_id": "mysql-cc8d1f5fa1e74b6bac93488149c5845f",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"LIKE": {
"node_id": "mysql-387801d5a5124f78a7bf3d68f3618a57",
"keywords": [
"like"
],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"JSON索引": {
"node_id": "mysql-9f8881b9f30544149327af68e3007603",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"组合索引": {
"node_id": "mysql-ce1f863b4d254d2aadb6ce2331122d16",
......@@ -1573,7 +1541,7 @@
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 2
}
},
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册