提交 769a1eed 编写于 作者: M Mars Liu

clean tree

上级 bb2e9bf8
......@@ -6,7 +6,10 @@
"subquery.json"
],
"keywords_must": [
["mysql", "相关子查询"]
[
"mysql",
"相关子查询"
]
],
"keywords_forbid": [],
"group": 1
......
{
"node_id": "mysql-8436069c855c4f1ead7cf11a026e004b",
"keywords": [],
"keywords": ["in", "subquery", "子查询"],
"children": [],
"export": [
"in.json"
......@@ -14,5 +14,5 @@
"keywords_forbid": [
"not in"
],
"group": 0
"group": 1
}
\ No newline at end of file
{
"node_id": "mysql-7645195ec078406c9303d39ea9c3738c",
"keywords": [],
"keywords": ["日志", "错误日志"],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
"group": 2
}
\ No newline at end of file
{
"node_id": "mysql-95a29a6a448849029d548393bbdf283e",
"keywords": [],
"children": [],
"export": [
"view.json"
],
"keywords_must": [
["mysql", "视图", "概念"]
],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "view.md",
"notebook_enable": false,
"exercise_id": "5335391d25d0428aa3dbe1759ac1ef37"
}
\ No newline at end of file
# 视图
关于 MySQL 的视图,以下哪些说法是正确的?
1. 视图可以看作预处理的查询
2. 视图可以作为表用在查询中
3. 包含主键的视图可以更新
4. 与源数据满足一一对应关系的视图可以更新
5. 包含列子查询的视图不能更新
6. 包含 distinct 的视图不能更新
7. 包含 union 或 union all 的视图不能更新
8. 可以给用户授予指定视图的 show view 权限,以控制其访问
## 答案
所有都对
## 选项
### A
所有都不对
### B
```
1, 2, 3, 4, 5
```
### C
```
2, 3, 4, 5, 6, 7, 8
```
### D
```
1, 3, 5, 7
```
### E
```
5, 6, 7, 8
```
### F
```
4, 5, 7
```
{
"node_id": "mysql-9339ebb389474492a0ba2c2ff29e78fb",
"keywords": [
"create view"
],
"children": [],
"export": [
"create_view.json"
],
"keywords_must": [
["mysql", "创建", "视图"]
],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "create_view.md",
"notebook_enable": false,
"exercise_id": "990e457f98db463b9fe14831f6ab2afc"
}
\ No newline at end of file
# 创建视图
Joe 想要基于
```mysql
create table employee(
id int primary key auto_increment,
name varchar(256),
address varchar(1024),
dept varchar(64)
-- ignore more
);
create table customer(
id int primary key auto_increment,
name varchar(256),
address varchar(1024),
level int
-- ignore more
)
```
创建视图 v_addresses,包含写姓名和地址两列。下列哪个正确?
## 答案
```mysql
create view v_addresses as
select name, address from employee
union
select name, address from customer;
```
## 选项
### A
```mysql
create view v_addresses as
select * from employee
union
select * from customer;
```
### B
```mysql
create view v_addresses as
select name, address from employee
union
select name, address from customer;
```
### C
```mysql
create view v_addresses as
begin;
select name, address from employee
select name, address from customer;
end;
```
### D
```mysql
create view v_addresses
select name, address from employee
union
select name, address from customer;
```
{
"type": "code_options",
"author": "ccat",
"source": "alter_view.md",
"notebook_enable": false,
"exercise_id": "a54d8dc829b64c78b63f3480af42e80e"
}
\ No newline at end of file
# 修改视图
针对用户表和员工表:
```mysql
create table employee(
id int primary key auto_increment,
name varchar(256),
address varchar(1024),
dept varchar(64)
-- ignore more
);
create table customer(
id int primary key auto_increment,
name varchar(256),
address varchar(1024),
level int
-- ignore more
)
```
Joe 建立了联系人视图:
```mysql
create view v_contacts as
select name, address from employee
union
select name, address from customer;
```
现在,他想要加入一列 catalog ,区分员工和顾客,下面哪一个做法是错的?
## 答案
```mysql
create if not exists view v_contacts as
select name, address, 'employee' as catalog from employee
union
select name, address, 'customer' as catalog from customer;
```
## 选项
## A
```mysql
alter view v_contacts as
select name, address, 'employee' as catalog from employee
union
select name, address, 'customer' as catalog from customer;
```
### B
```mysql
create or replace view v_contacts as
select name, address, 'employee' as catalog from employee
union
select name, address, 'customer' as catalog from customer;
```
### C
```mysql
drop view v_contacts;
create view v_contacts as
select name, address, 'employee' as catalog from employee
union
select name, address, 'customer' as catalog from customer;
```
\ No newline at end of file
{
"node_id": "mysql-3a51b0740b704d92a534335a7a8dfd6e",
"keywords": [],
"children": [],
"export": [
"alter_view.json"
],
"keywords_must": [
["mysql", "修改", "视图"]
],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-36171582b8324dc98ff16d9b0cac406d",
"keywords": [],
"children": [],
"export": [
"drop_view.json"
],
"keywords_must": [
["mysql", "删除", "视图"]
],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "drop_view.md",
"notebook_enable": false,
"exercise_id": "3ef595b611414ae7957ffa93a91a5b99"
}
\ No newline at end of file
# 删除视图
Joe 建立了联系人视图:
```mysql
create view v_contacts as
select name, address from employee
union
select name, address from customer;
```
现在,他完成了相关工作,想要删掉这个视图,应该执行哪个操作?
## 答案
```mysql
drop view v_contacts;
```
## 选项
## A
```mysql
delete from v_contacts;
```
### B
```mysql
delete from v_contacts where 1=1;
```
### C
```mysql
truncate table v_contacts;
```
\ No newline at end of file
{
"node_id": "mysql-076c43405cd941c8ba947f7b08d35005",
"keywords": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 1
}
\ No newline at end of file
{
"node_id": "mysql-0666cae9faaa41b7b2413063e1214edd",
"keywords": [],
"children": [],
"export": [
"tax.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "tax.md",
"notebook_enable": false,
"exercise_id": "bc846ce638304b27a51ae20299120b98"
}
\ No newline at end of file
# 个人所得税计算
个人所得税的计算需要进行若干指标的求和,然后基于分段的基数和系数计算得到扣税金额。
因此 Joe 准备用一个存储过程或函数将个人所得税计算封装起来,供团队使用,那么,下列
措施中哪一项是错误的?
## 答案
通过 `create function iitax(amount decimal(12, 4), out tax decimal(12, 4), out rest decimal(12, 4)) `
定义个人所得税计算函数。
## 选项
### A
通过 `create function iitax(amount decimal(12, 4)) returns decimal(12, 4)` 定义个人所得税计算函数。
### B
通过 `create procedure(amount decimal(12, 4), out tax decimal(12, 4), out rest decimal(12, 4))`
定义计算过程,将税金和剩余金额通过 out 参数传递出来。
### C
通过 `select iitax(amount)` 可以调用 iitax 函数得到所得税金额。
### D
通过 `call iitax(amount, @tax, @rest)` 可以求得 amount 对应的个人所得税金额,
并将税额和剩余金额保存在 `@tax``@rest` 变量中。
\ No newline at end of file
{
"node_id": "mysql-101770860dbe48ad92566d296809b34d",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-5af12dac5321409baa0479ba2824e0bf",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-9d19fedcc1fd48c9a450e71403b9099f",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-2fd94590dfca4068bc713bbf132f8653",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-24789b2078dc4f44b8ad150ce571314e",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-cece7ee8078441a6a032cf1a71cac21c",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-586f686edd1e4ccbbc68f9a6e1548f57",
"keywords": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 2
}
\ No newline at end of file
{
"node_id": "mysql-6724aaaef7d3404fb06d322f9d9534ed",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-ec8ee43f3a6340638362d38157fbc66b",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-876f66d6f6404fe8813a932df024cb5d",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-5ea983e0874547bd956ef0be606f3424",
"keywords": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 2
}
\ No newline at end of file
......@@ -995,169 +995,6 @@
"group": 1
}
},
{
"连接查询": {
"node_id": "mysql-e12eca4c9358429f9222a3f32e1798f6",
"keywords": [
"join",
"连接查询"
],
"children": [
{
"INNER JOIN": {
"node_id": "mysql-73bfbd883511436c85130b71fa108038",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"inner join"
]
],
"keywords_forbid": [],
"group": 0
}
},
{
" LEFT JOIN": {
"node_id": "mysql-d7a8869fb798498c839c913ce930015d",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"left join"
]
],
"keywords_forbid": [],
"group": 0
}
},
{
" RIGHT JOIN": {
"node_id": "mysql-7c2331eea3e84eef9464ad4d7c03e2de",
"keywords": [
"right join",
"右连接"
],
"children": [],
"keywords_must": [
[
"mysql",
"right join"
]
],
"keywords_forbid": [],
"group": 0
}
},
{
" CROSS JOIN": {
"node_id": "mysql-fd27af20b046463eac7b2712885ac018",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"cross join"
]
],
"keywords_forbid": [],
"group": 0
}
},
{
" 复杂连接": {
"node_id": "mysql-a4773004e0cf432aa7ccdf6b9490838f",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"复杂连接"
]
],
"keywords_forbid": [],
"group": 1
}
}
],
"keywords_must": [
"join",
"连接查询"
],
"keywords_forbid": [],
"group": 1
}
},
{
" 索引": {
"node_id": "mysql-6ac51e7a042849f6a5f9c52a1cd1e347",
"keywords": [],
"children": [
{
"索引入门": {
"node_id": "mysql-bf629829370d405cbfcd5aa83adb536a",
"keywords": [
"index",
"index"
],
"children": [],
"keywords_must": [
[
"mysql",
"索引",
"入门"
]
],
"keywords_forbid": [],
"group": 1
}
},
{
"创建索引": {
"node_id": "mysql-fe65d5c615ad40f8ac056cc654f2d788",
"keywords": [
"create index",
"创建索引"
],
"children": [],
"keywords_must": [
[
"mysql",
"创建",
"索引"
]
],
"keywords_forbid": [],
"group": 1
}
},
{
"删除索引": {
"node_id": "mysql-85ba0df78d754b00b30aa8e74ad35d06",
"keywords": [
"删除索引",
"drop index"
],
"children": [],
"keywords_must": [
[
"mysql",
"删除",
"索引"
]
],
"keywords_forbid": [],
"group": 1
}
}
],
"keywords_must": [],
"keywords_forbid": [],
"group": 1
}
},
{
"子查询": {
"node_id": "mysql-787937c95738421ba7b1d5b8aafe55d0",
......@@ -1277,20 +1114,22 @@
}
},
{
"视图": {
"node_id": "mysql-076c43405cd941c8ba947f7b08d35005",
"keywords": [],
"连接查询": {
"node_id": "mysql-e12eca4c9358429f9222a3f32e1798f6",
"keywords": [
"join",
"连接查询"
],
"children": [
{
"视图的基本概念": {
"node_id": "mysql-95a29a6a448849029d548393bbdf283e",
"INNER JOIN": {
"node_id": "mysql-73bfbd883511436c85130b71fa108038",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"视图",
"概念"
"inner join"
]
],
"keywords_forbid": [],
......@@ -1298,17 +1137,14 @@
}
},
{
" 创建视图": {
"node_id": "mysql-9339ebb389474492a0ba2c2ff29e78fb",
"keywords": [
"create view"
],
" LEFT JOIN": {
"node_id": "mysql-d7a8869fb798498c839c913ce930015d",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"创建",
"视图"
"left join"
]
],
"keywords_forbid": [],
......@@ -1316,15 +1152,17 @@
}
},
{
" 修改视图": {
"node_id": "mysql-3a51b0740b704d92a534335a7a8dfd6e",
"keywords": [],
" RIGHT JOIN": {
"node_id": "mysql-7c2331eea3e84eef9464ad4d7c03e2de",
"keywords": [
"right join",
"右连接"
],
"children": [],
"keywords_must": [
[
"mysql",
"修改",
"视图"
"right join"
]
],
"keywords_forbid": [],
......@@ -1332,147 +1170,110 @@
}
},
{
" 删除视图": {
"node_id": "mysql-36171582b8324dc98ff16d9b0cac406d",
" CROSS JOIN": {
"node_id": "mysql-fd27af20b046463eac7b2712885ac018",
"keywords": [],
"children": [],
"keywords_must": [
[
"mysql",
"删除",
"视图"
"cross join"
]
],
"keywords_forbid": [],
"group": 0
}
}
],
"keywords_must": [],
"keywords_forbid": [],
"group": 1
}
},
{
"存储过程和函数": {
"node_id": "mysql-586f686edd1e4ccbbc68f9a6e1548f57",
"keywords": [],
"children": [
{
"存储过程和函数简介": {
"node_id": "mysql-0666cae9faaa41b7b2413063e1214edd",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"创建存储过程和函数": {
"node_id": "mysql-101770860dbe48ad92566d296809b34d",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"查看存储过程和函数": {
"node_id": "mysql-5af12dac5321409baa0479ba2824e0bf",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"修改存储过程和函数": {
"node_id": "mysql-9d19fedcc1fd48c9a450e71403b9099f",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"调用存储过程和函数": {
"node_id": "mysql-2fd94590dfca4068bc713bbf132f8653",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"删除存储过程和函数": {
"node_id": "mysql-24789b2078dc4f44b8ad150ce571314e",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
},
{
"变量": {
"node_id": "mysql-cece7ee8078441a6a032cf1a71cac21c",
" 复杂连接": {
"node_id": "mysql-a4773004e0cf432aa7ccdf6b9490838f",
"keywords": [],
"children": [],
"keywords_must": [],
"keywords_must": [
[
"mysql",
"复杂连接"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
}
],
"keywords_must": [],
"keywords_must": [
"join",
"连接查询"
],
"keywords_forbid": [],
"group": 2
"group": 1
}
},
{
"触发器": {
"node_id": "mysql-5ea983e0874547bd956ef0be606f3424",
" 索引": {
"node_id": "mysql-6ac51e7a042849f6a5f9c52a1cd1e347",
"keywords": [],
"children": [
{
"创建触发器": {
"node_id": "mysql-6724aaaef7d3404fb06d322f9d9534ed",
"keywords": [],
"索引入门": {
"node_id": "mysql-bf629829370d405cbfcd5aa83adb536a",
"keywords": [
"index",
"index"
],
"children": [],
"keywords_must": [],
"keywords_must": [
[
"mysql",
"索引",
"入门"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
"查看触发器": {
"node_id": "mysql-ec8ee43f3a6340638362d38157fbc66b",
"keywords": [],
"创建索引": {
"node_id": "mysql-fe65d5c615ad40f8ac056cc654f2d788",
"keywords": [
"create index",
"创建索引"
],
"children": [],
"keywords_must": [],
"keywords_must": [
[
"mysql",
"创建",
"索引"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
},
{
"删除触发器": {
"node_id": "mysql-876f66d6f6404fe8813a932df024cb5d",
"keywords": [],
"删除索引": {
"node_id": "mysql-85ba0df78d754b00b30aa8e74ad35d06",
"keywords": [
"删除索引",
"drop index"
],
"children": [],
"keywords_must": [],
"keywords_must": [
[
"mysql",
"删除",
"索引"
]
],
"keywords_forbid": [],
"group": 0
"group": 1
}
}
],
"keywords_must": [],
"keywords_forbid": [],
"group": 2
"group": 1
}
},
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册