Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_mysql
提交
a217dd69
S
skill_tree_mysql
项目概览
CSDN 技术社区
/
skill_tree_mysql
通知
21
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_mysql
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a217dd69
编写于
5月 31, 2022
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
loop
上级
7ec23737
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
183 addition
and
48 deletion
+183
-48
data/3.MySQL高阶/4. 过程化编程/1.IF/config.json
data/3.MySQL高阶/4. 过程化编程/1.IF/config.json
+3
-1
data/3.MySQL高阶/4. 过程化编程/1.IF/if.json
data/3.MySQL高阶/4. 过程化编程/1.IF/if.json
+8
-0
data/3.MySQL高阶/4. 过程化编程/1.IF/if.md
data/3.MySQL高阶/4. 过程化编程/1.IF/if.md
+56
-0
data/3.MySQL高阶/4. 过程化编程/2.LOOP/config.json
data/3.MySQL高阶/4. 过程化编程/2.LOOP/config.json
+7
-2
data/3.MySQL高阶/4. 过程化编程/2.LOOP/loop.json
data/3.MySQL高阶/4. 过程化编程/2.LOOP/loop.json
+8
-0
data/3.MySQL高阶/4. 过程化编程/2.LOOP/loop.md
data/3.MySQL高阶/4. 过程化编程/2.LOOP/loop.md
+95
-0
data/3.MySQL高阶/4. 过程化编程/3.LEAVE/config.json
data/3.MySQL高阶/4. 过程化编程/3.LEAVE/config.json
+0
-10
data/3.MySQL高阶/4. 过程化编程/3.REPEAT/config.json
data/3.MySQL高阶/4. 过程化编程/3.REPEAT/config.json
+0
-0
data/3.MySQL高阶/4. 过程化编程/4.ITERATE/config.json
data/3.MySQL高阶/4. 过程化编程/4.ITERATE/config.json
+0
-10
data/3.MySQL高阶/4. 过程化编程/4.WHILE/config.json
data/3.MySQL高阶/4. 过程化编程/4.WHILE/config.json
+1
-1
data/3.MySQL高阶/4. 过程化编程/5. 游标/config.json
data/3.MySQL高阶/4. 过程化编程/5. 游标/config.json
+0
-0
data/tree.json
data/tree.json
+5
-24
未找到文件。
data/3.MySQL高阶/4. 过程化编程/1.IF/config.json
浏览文件 @
a217dd69
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
"node_id"
:
"mysql-d7f86bc2fcbb4b83a11f2ed73bde7ac0"
,
"node_id"
:
"mysql-d7f86bc2fcbb4b83a11f2ed73bde7ac0"
,
"keywords"
:
[],
"keywords"
:
[],
"children"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"if.json"
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
0
...
...
data/3.MySQL高阶/4. 过程化编程/1.IF/if.json
0 → 100644
浏览文件 @
a217dd69
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"if.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"19cc93e63f0946069ce30e4be5af4e2a"
}
\ No newline at end of file
data/3.MySQL高阶/4. 过程化编程/1.IF/if.md
0 → 100644
浏览文件 @
a217dd69
# 判断
Goods 数据库中有一个名为 trade 的存储过程,封装了交易过程,每一笔交易,trade都会被调用一次。Joe
想在 trade 里加一段逻辑,实现:
1.
每一次交易,对 @counter 变量加一
2.
如果 @counter 是 1000 的整倍数,就将 @total_price 变量乘 0.8。
下面哪一段代码可以实现这个逻辑?
## 答案
```
mysql
set @counter = @counter + 1;
if @counter % 1000 = 0 then
set @total_price = @total_price * 0.8;
end if;
```
## 选项
### A
```
mysql
set @counter = @counter + 1;
if @counter % 1000 = 0 {
set @total_price = @total_price * 0.8;
}
```
### B
```
mysql
set @counter = @counter + 1;
if (@counter % 1000 = 0) {
set @total_price = @total_price * 0.8;
}
```
### C
```
mysql
if @counter % 1000 = 0 begin ;
set @total_price = @total_price * 0.8;
end;
```
### D
```
mysql
set @counter ++;
if @counter % 1000 = 0 then begin
select @total_price = @total_price * 0.8;
end;
```
\ No newline at end of file
data/3.MySQL高阶/4. 过程化编程/2.LOOP/config.json
浏览文件 @
a217dd69
{
{
"node_id"
:
"mysql-8ef7f9a1bba04bd782d80e9459446228"
,
"node_id"
:
"mysql-8ef7f9a1bba04bd782d80e9459446228"
,
"keywords"
:
[
"loop"
,
"循环"
],
"keywords"
:
[
"loop"
,
"循环"
],
"children"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"loop.json"
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
0
...
...
data/3.MySQL高阶/4. 过程化编程/2.LOOP/loop.json
0 → 100644
浏览文件 @
a217dd69
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"loop.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"7cca3eff58b1408ea98a8fa363b2c771"
}
\ No newline at end of file
data/3.MySQL高阶/4. 过程化编程/2.LOOP/loop.md
0 → 100644
浏览文件 @
a217dd69
# Loop 循环
封装订单交易过程的 trade procedure 中有一个循环,会遍历订单中的商品项目,如果当前的商品价格
`@price`
大于 1000,则将其价格乘 0.9 ,如果
`@total_price`
变量中的总价已经超过 20000,则跳出循环。否则进行
下一个商品项目的处理。这个循环应该是(这里不考虑每个项目本身的处理逻辑,仅考虑折扣和商品订单分割):
## 答案
```
mysql
-- ...
trade: LOOP
if @price > 1000 then
set @price = @price * 0.9;
end if;
-- ...
if @total_price > 20000 then
LEAVE trade;
else
ITERATE trade;
end if;
-- ...
end LOOP trace;
```
## 选项
### A
```
mysql
-- ...
trade: LOOP
if @price > 1000 then
set @price = @price * 0.9;
end if;
-- ...
if @total_price > 20000 then
LEAVE trade;
end if;
-- ...
end LOOP trace;
```
### B
```
mysql
-- ...
trade: LOOP
if @price > 1000 then
set @price = @price * 0.9;
end if;
-- ...
if @total_price > 20000 then
ITERATE trade;
else
LEAVE trade;
end if;
-- ...
end LOOP trace;
```
### C
```
mysql
-- ...
trade: LOOP
if @price > 1000 then
set @price = @price * 0.9;
end if;
-- ...
if @total_price > 20000 then
LEAVE trade;
else
NEXT trade;
end if;
-- ...
end LOOP trace;
```
### D
```
mysql
-- ...
trade: LOOP
if @price > 1000 then
set @price = @price * 0.9;
end if;
-- ...
if @total_price > 20000 then
LEAVE trade;
end if;
NEXT trade;
-- ...
end LOOP trace;
```
data/3.MySQL高阶/4. 过程化编程/3.LEAVE/config.json
已删除
100644 → 0
浏览文件 @
7ec23737
{
"node_id"
:
"mysql-2f35dac71e6e42b189f7615fcf27a4e6"
,
"keywords"
:
[
"leave"
,
"break"
],
"children"
:
[],
"export"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
\ No newline at end of file
data/3.MySQL高阶/4. 过程化编程/
5
.REPEAT/config.json
→
data/3.MySQL高阶/4. 过程化编程/
3
.REPEAT/config.json
浏览文件 @
a217dd69
文件已移动
data/3.MySQL高阶/4. 过程化编程/4.ITERATE/config.json
已删除
100644 → 0
浏览文件 @
7ec23737
{
"node_id"
:
"mysql-cf916e42a060467ab25b16112780f246"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
\ No newline at end of file
data/3.MySQL高阶/4. 过程化编程/
6
.WHILE/config.json
→
data/3.MySQL高阶/4. 过程化编程/
4
.WHILE/config.json
浏览文件 @
a217dd69
{
{
"node_id"
:
"mysql-8bbe6f55f32b4a4a8a6011c5748b36fa"
,
"node_id"
:
"mysql-8bbe6f55f32b4a4a8a6011c5748b36fa"
,
"keywords"
:
[],
"keywords"
:
[
"while"
],
"children"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[],
"keywords_must"
:
[],
"keywords_must"
:
[],
...
...
data/3.MySQL高阶/4. 过程化编程/
7
. 游标/config.json
→
data/3.MySQL高阶/4. 过程化编程/
5
. 游标/config.json
浏览文件 @
a217dd69
文件已移动
data/tree.json
浏览文件 @
a217dd69
...
@@ -2177,29 +2177,6 @@
...
@@ -2177,29 +2177,6 @@
"group"
:
0
"group"
:
0
}
}
},
},
{
"LEAVE"
:
{
"node_id"
:
"mysql-2f35dac71e6e42b189f7615fcf27a4e6"
,
"keywords"
:
[
"leave"
,
"break"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
},
{
"ITERATE"
:
{
"node_id"
:
"mysql-cf916e42a060467ab25b16112780f246"
,
"keywords"
:
[],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
},
{
{
"REPEAT"
:
{
"REPEAT"
:
{
"node_id"
:
"mysql-923c7bbf96cf4630a5dfb36f15e62d24"
,
"node_id"
:
"mysql-923c7bbf96cf4630a5dfb36f15e62d24"
,
...
@@ -2508,7 +2485,11 @@
...
@@ -2508,7 +2485,11 @@
{
{
"GROUP BY优化"
:
{
"GROUP BY优化"
:
{
"node_id"
:
"mysql-66fc4566eaf34994b072ca83bf79ceb4"
,
"node_id"
:
"mysql-66fc4566eaf34994b072ca83bf79ceb4"
,
"keywords"
:
[],
"keywords"
:
[
"performance"
,
"优化"
,
"group by"
],
"children"
:
[],
"children"
:
[],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录