Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_oceanbase
提交
da725e79
S
skill_tree_oceanbase
项目概览
CSDN 技术社区
/
skill_tree_oceanbase
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
da725e79
编写于
11月 04, 2021
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add dml and commit exercise
上级
bcadc0f1
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
222 addition
and
5 deletion
+222
-5
data/2.OceanBase中阶/4.INSERT/config.json
data/2.OceanBase中阶/4.INSERT/config.json
+4
-1
data/2.OceanBase中阶/4.INSERT/insert.json
data/2.OceanBase中阶/4.INSERT/insert.json
+6
-0
data/2.OceanBase中阶/4.INSERT/insert.md
data/2.OceanBase中阶/4.INSERT/insert.md
+31
-0
data/2.OceanBase中阶/5.UPDATE/config.json
data/2.OceanBase中阶/5.UPDATE/config.json
+4
-1
data/2.OceanBase中阶/5.UPDATE/update.json
data/2.OceanBase中阶/5.UPDATE/update.json
+6
-0
data/2.OceanBase中阶/5.UPDATE/update.md
data/2.OceanBase中阶/5.UPDATE/update.md
+30
-0
data/2.OceanBase中阶/6.DELETE/config.json
data/2.OceanBase中阶/6.DELETE/config.json
+3
-1
data/2.OceanBase中阶/6.DELETE/delete.json
data/2.OceanBase中阶/6.DELETE/delete.json
+6
-0
data/2.OceanBase中阶/6.DELETE/delete.md
data/2.OceanBase中阶/6.DELETE/delete.md
+30
-0
data/2.OceanBase中阶/7.REPLACE/config.json
data/2.OceanBase中阶/7.REPLACE/config.json
+3
-1
data/2.OceanBase中阶/7.REPLACE/replace.json
data/2.OceanBase中阶/7.REPLACE/replace.json
+6
-0
data/2.OceanBase中阶/7.REPLACE/replace.md
data/2.OceanBase中阶/7.REPLACE/replace.md
+42
-0
data/2.OceanBase中阶/8.提交事务/config.json
data/2.OceanBase中阶/8.提交事务/config.json
+3
-1
data/2.OceanBase中阶/8.提交事务/transaction.json
data/2.OceanBase中阶/8.提交事务/transaction.json
+6
-0
data/2.OceanBase中阶/8.提交事务/transaction.md
data/2.OceanBase中阶/8.提交事务/transaction.md
+42
-0
未找到文件。
data/2.OceanBase中阶/4.INSERT/config.json
浏览文件 @
da725e79
{
{
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
"oceanbase-4d176da86e544f98acdb7b473d14902a"
,
"node_id"
:
"oceanbase-4d176da86e544f98acdb7b473d14902a"
,
"title"
:
"INSERT"
"title"
:
"INSERT"
,
"notebook_enable"
:
false
,
"export"
:
[
"insert.json"
]
}
}
\ No newline at end of file
data/2.OceanBase中阶/4.INSERT/insert.json
0 → 100644
浏览文件 @
da725e79
{
"type"
:
"code_options"
,
"author"
:
"刘鑫"
,
"source"
:
"insert.md"
}
\ No newline at end of file
data/2.OceanBase中阶/4.INSERT/insert.md
0 → 100644
浏览文件 @
da725e79
# Insert
下列哪一个选项的插入语句有错误?
## 答案
```
sql
insert
into
cust
set
first_name
=
'Mars'
,
last_name
=
'Liu'
,
city
=
'Tian Jin'
;
```
## 选项
### 标准插入语句
```
sql
insert
into
cust
(
first_name
,
last_name
,
city
)
values
(
'Mars'
,
'Liu'
,
'Tian Jin'
);
```
### insert 可以使用 select 子句
```
sql
insert
into
cust
(
first_name
,
last_name
,
city
)
select
'Mars'
,
'Liu'
,
'Tian Jin'
;
```
### insert 可以插入多条 values
```
sql
insert
into
cust
(
first_name
,
last_name
,
city
)
values
(
'Mars'
,
'Liu'
,
'Tian Jin'
),
(
'Milly'
,
'Lee'
,
'Tian Jin'
);
```
\ No newline at end of file
data/2.OceanBase中阶/5.UPDATE/config.json
浏览文件 @
da725e79
{
{
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
"oceanbase-331c385ebc2448198f48564851555c06"
,
"node_id"
:
"oceanbase-331c385ebc2448198f48564851555c06"
,
"title"
:
"UPDATE"
"title"
:
"UPDATE"
,
"notebook_enable"
:
false
,
"export"
:
[
"update.json"
]
}
}
\ No newline at end of file
data/2.OceanBase中阶/5.UPDATE/update.json
0 → 100644
浏览文件 @
da725e79
{
"type"
:
"code_options"
,
"author"
:
"刘鑫"
,
"source"
:
"update.md"
}
\ No newline at end of file
data/2.OceanBase中阶/5.UPDATE/update.md
0 → 100644
浏览文件 @
da725e79
# Update
下面选项中,有错的是:
## 答案
```
sql
update
cust
(
first_name
)
values
(
'mars'
);
```
## 选项
### 生产环境下不带 where 的update 通常是极度危险的,但是合法
```
sql
update
cust
set
first_name
=
'Mars'
;
```
### 标准 sql
```
sql
update
cust
set
first_name
=
'Mars'
where
id
=
1234
;
```
### Update 多个字段也是常用操作
```
sql
update
cust
set
first_name
=
'Mars'
,
last_name
=
'Liu'
where
id
=
1234
;
```
\ No newline at end of file
data/2.OceanBase中阶/6.DELETE/config.json
浏览文件 @
da725e79
{
{
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
"oceanbase-704cfa03b69449b4bed5dc753bf5b7e7"
,
"node_id"
:
"oceanbase-704cfa03b69449b4bed5dc753bf5b7e7"
,
"title"
:
"DELETE"
"title"
:
"DELETE"
,
"export"
:
"delete.json"
}
}
\ No newline at end of file
data/2.OceanBase中阶/6.DELETE/delete.json
0 → 100644
浏览文件 @
da725e79
{
"type"
:
"code_options"
,
"author"
:
"刘鑫"
,
"source"
:
"delete.md"
}
\ No newline at end of file
data/2.OceanBase中阶/6.DELETE/delete.md
0 → 100644
浏览文件 @
da725e79
# Delete
下列删除语句中,有错误的是:
## 答案
```
sql
delete
from
cust
(
id
,
last_name
,
first_name
,
city
)
where
id
=
5
;
```
## 选项
### 在生产环境不带 where 的 delete 是极度危险的操作,但是它仍然合法
```
sql
delete
from
cust
;
```
### 标准的删除操作
```
sql
delete
from
cust
where
id
=
2341
;
```
### 删除操作可以带有子查询
```
sql
delete
from
cust
where
id
in
(
select
id
from
cust
where
city
=
'Tian Jin'
);
```
data/2.OceanBase中阶/7.REPLACE/config.json
浏览文件 @
da725e79
{
{
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
"oceanbase-2884a0055c714346ba751c2f653e8445"
,
"node_id"
:
"oceanbase-2884a0055c714346ba751c2f653e8445"
,
"title"
:
"REPLACE"
"title"
:
"REPLACE"
,
"export"
:
[
"replace.json"
]
}
}
\ No newline at end of file
data/2.OceanBase中阶/7.REPLACE/replace.json
0 → 100644
浏览文件 @
da725e79
{
"type"
:
"code_options"
,
"author"
:
"刘鑫"
,
"source"
:
"replace.md"
}
\ No newline at end of file
data/2.OceanBase中阶/7.REPLACE/replace.md
0 → 100644
浏览文件 @
da725e79
# Replace
假设有数据表如下
```
sql
create
table
cust
(
id
integer
primary
key
,
first_name
varchar
(
256
),
last_name
varchar
(
256
),
city
varchar
(
256
)
);
```
下列replace语句中,有错误的是:
## 答案
```
sql
replace
into
cust
(
id
)
set
first_name
=
'Mars'
,
last_name
=
'Liu'
where
id
=
6
;
```
## 选项
### 标准的 replace
```
sql
REPLACE
INTO
cust
(
id
,
first_name
,
last_name
,
city
)
values
(
1
,
'Mars'
,
'Liu'
,
'Tian Jin'
);
```
### 合法的插入操作
```
sql
REPLACE
INTO
cust
(
first_name
,
last_name
,
city
)
values
(
'Mars'
,
'Liu'
,
'Tian Jin'
);
```
### 合法的插入操作
```
sql
REPLACE
INTO
cust
(
first_name
,
last_name
,
city
)
SELECT
first_name
,
last_name
,
city
FROM
book
;
```
\ No newline at end of file
data/2.OceanBase中阶/8.提交事务/config.json
浏览文件 @
da725e79
{
{
"keywords"
:
[],
"keywords"
:
[],
"node_id"
:
"oceanbase-8526e5c5374b4081b9a5c698b9748856"
,
"node_id"
:
"oceanbase-8526e5c5374b4081b9a5c698b9748856"
,
"title"
:
"提交事务"
"title"
:
"提交事务"
,
"export"
:
"transaction.json"
}
}
\ No newline at end of file
data/2.OceanBase中阶/8.提交事务/transaction.json
0 → 100644
浏览文件 @
da725e79
{
"type"
:
"code_options"
,
"author"
:
"刘鑫"
,
"source"
:
"transaction.md"
}
\ No newline at end of file
data/2.OceanBase中阶/8.提交事务/transaction.md
0 → 100644
浏览文件 @
da725e79
# Transaction
下列选项中,哪个可以正确的保证 channel 表和 posts 表的同步修改?
## 答案
```
sql
begin
;
insert
into
posts
(
title
,
content
)
select
?
,
?
;
update
channel
set
posts
=
posts
+
1
where
channel_id
=
?
;
commit
;
```
## 选项
### 没有 commit
```
sql
begin
;
insert
into
posts
(
title
,
content
)
select
?
,
?
;
update
channel
set
posts
=
posts
+
1
where
channel_id
=
?
;
end
;
```
### 没有创建事务
```
sql
insert
into
posts
(
title
,
content
)
select
?
,
?
;
update
channel
set
posts
=
posts
+
1
where
channel_id
=
?
;
commit
;
```
### 多次提交
```
sql
begin
;
insert
into
posts
(
title
,
content
)
select
?
,
?
;
commit
;
update
channel
set
posts
=
posts
+
1
where
channel_id
=
?
;
commit
;
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录