Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_mysql
提交
2de7db37
S
skill_tree_mysql
项目概览
CSDN 技术社区
/
skill_tree_mysql
通知
22
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看板
提交
2de7db37
编写于
5月 24, 2022
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
operator
上级
9adba7b6
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
371 addition
and
7 deletion
+371
-7
data/1.MySQL初阶/5.数据修改/2.修改/config.json
data/1.MySQL初阶/5.数据修改/2.修改/config.json
+3
-1
data/1.MySQL初阶/5.数据修改/2.修改/update.json
data/1.MySQL初阶/5.数据修改/2.修改/update.json
+8
-0
data/1.MySQL初阶/5.数据修改/2.修改/update.md
data/1.MySQL初阶/5.数据修改/2.修改/update.md
+43
-0
data/1.MySQL初阶/5.数据修改/3.删除/config.json
data/1.MySQL初阶/5.数据修改/3.删除/config.json
+3
-1
data/1.MySQL初阶/5.数据修改/3.删除/delete.json
data/1.MySQL初阶/5.数据修改/3.删除/delete.json
+8
-0
data/1.MySQL初阶/5.数据修改/3.删除/delete.md
data/1.MySQL初阶/5.数据修改/3.删除/delete.md
+91
-0
data/1.MySQL初阶/6.数据查询/1.SELECT/config.json
data/1.MySQL初阶/6.数据查询/1.SELECT/config.json
+4
-2
data/1.MySQL初阶/6.数据查询/1.SELECT/select.json
data/1.MySQL初阶/6.数据查询/1.SELECT/select.json
+8
-0
data/1.MySQL初阶/6.数据查询/1.SELECT/select.md
data/1.MySQL初阶/6.数据查询/1.SELECT/select.md
+43
-0
data/1.MySQL初阶/6.数据查询/2.WHERE/config.json
data/1.MySQL初阶/6.数据查询/2.WHERE/config.json
+3
-1
data/1.MySQL初阶/6.数据查询/2.WHERE/where.json
data/1.MySQL初阶/6.数据查询/2.WHERE/where.json
+8
-0
data/1.MySQL初阶/6.数据查询/2.WHERE/where.md
data/1.MySQL初阶/6.数据查询/2.WHERE/where.md
+64
-0
data/1.MySQL初阶/6.数据查询/3.运算符/config.json
data/1.MySQL初阶/6.数据查询/3.运算符/config.json
+7
-2
data/1.MySQL初阶/6.数据查询/3.运算符/geo.json
data/1.MySQL初阶/6.数据查询/3.运算符/geo.json
+8
-0
data/1.MySQL初阶/6.数据查询/3.运算符/geo.md
data/1.MySQL初阶/6.数据查询/3.运算符/geo.md
+46
-0
gears/sql/goods.sql
gears/sql/goods.sql
+9
-0
gears/sql/orders.sql
gears/sql/orders.sql
+10
-0
gears/sql/points.sql
gears/sql/points.sql
+5
-0
未找到文件。
data/1.MySQL初阶/5.数据修改/2.修改/config.json
浏览文件 @
2de7db37
...
...
@@ -2,7 +2,9 @@
"node_id"
:
"mysql-2eb9e9d351e848f580b70cf9e7b93280"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"update.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
...
...
data/1.MySQL初阶/5.数据修改/2.修改/update.json
0 → 100644
浏览文件 @
2de7db37
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"update.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"cf4476a1954440b499c84e022ec463ea"
}
\ No newline at end of file
data/1.MySQL初阶/5.数据修改/2.修改/update.md
0 → 100644
浏览文件 @
2de7db37
# 更新数据
现有 employee 表如下:
```
mysql
create table employee
(
id serial primary key,
name text,
dept text,
salary money
);
```
Joe 希望修改销售部(dept 字段为 sale)员工 Dora Muk 的工资,将其增加 1000。正确的修改语句是:
## 答案
```
mysql
update employee set salary = salary + 1000 where dept = 'sale' and name = 'Dora Muk';
```
## 选项
### 过滤条件不严谨
```
mysql
update employee set salary = salary + 1000 where name = 'Dora Muk';
```
### 缺少过滤条件
```
mysql
update employee set salary = salary + 1000;
```
### 错误的赋值语句
```
mysql
update employee set salary += 1000;
```
data/1.MySQL初阶/5.数据修改/3.删除/config.json
浏览文件 @
2de7db37
...
...
@@ -2,7 +2,9 @@
"node_id"
:
"mysql-3cae643e21644d6d937d69b59014922f"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"delete.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
...
...
data/1.MySQL初阶/5.数据修改/3.删除/delete.json
0 → 100644
浏览文件 @
2de7db37
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"delete.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"cfdd2c9789fd4fe493541cfa8811e4c9"
}
\ No newline at end of file
data/1.MySQL初阶/5.数据修改/3.删除/delete.md
0 → 100644
浏览文件 @
2de7db37
# 删除
现在 orders 表结构如下:
```
mysql
create table orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
total_price decimal(12, 4),
description varchar(2000),
ts timestamp default now(),
deal bool default false
);
```
有一个业务系统会实时的将已经成交(deal 字段为 true)的订单数据转储,现在我们仅需要一个清理 程序,将已经成 交的数据从 orders 表删除并记录被删除的数据id。下面哪个操作是对的?
## 答案
在一个独立的定时任务中执行
```
mysql
delete
from orders
where deal;
```
## 选项
### A
在一个独立的定时任务中执行
```
mysql
truncate orders;
```
### B
在一个独立的定时任务中执行
```
mysql
delete
from orders;
```
### C
在一个独立的定时任务中执行
```
mysql
drop table orders;
create table if not exists orders (
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
total_price decimal(12, 4),
description varchar(2000),
ts timestamp default now(),
deal bool default false
);
```
### D
建立视图
```
mysql
create view order_view as
select id, meta, content, created_at
from orders
where not deal;
```
并要求业务系统只能访问这个视图。
### E
在一个独立的定时任务中执行
```
mysql
delete
from orders
where deal;
```
并记录操作前后表中的最大 id
\ No newline at end of file
data/1.MySQL初阶/6.数据查询/1.SELECT/config.json
浏览文件 @
2de7db37
{
"node_id"
:
"mysql-f5527eae7f3148108c92ff99a6d4ed4a"
,
"keywords"
:
[],
"keywords"
:
[
"查询"
,
"select"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"select.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
...
...
data/1.MySQL初阶/6.数据查询/1.SELECT/select.json
0 → 100644
浏览文件 @
2de7db37
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"select.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"c873b09db60f4f93a8603a15e31d2a3a"
}
\ No newline at end of file
data/1.MySQL初阶/6.数据查询/1.SELECT/select.md
0 → 100644
浏览文件 @
2de7db37
# 基本语法
下列 SQL 语句,哪一项不合法?
## 答案
```
mysql
from test select abc;
```
## 选项
### A
```
mysql
select 3.14;
```
### B
```
mysql
select * from employee;
```
### C
```
mysql
select * from employee where dept = 'hr';
```
### D
```
mysql
select id, name, dept, salary from employee where salary > 10000;
```
### E
```
mysql
select now();
```
data/1.MySQL初阶/6.数据查询/2.WHERE/config.json
浏览文件 @
2de7db37
...
...
@@ -2,7 +2,9 @@
"node_id"
:
"mysql-91cc9c73e58945d3ba654370a057a1c7"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"where.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
...
...
data/1.MySQL初阶/6.数据查询/2.WHERE/where.json
0 → 100644
浏览文件 @
2de7db37
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"where.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"1407e367ecca4e159cb7777fe141e8d4"
}
\ No newline at end of file
data/1.MySQL初阶/6.数据查询/2.WHERE/where.md
0 → 100644
浏览文件 @
2de7db37
# Where 条件
Joe 希望从 orders 表
```
mysql
create table orders
(
id int primary key auto_increment,
item_id int,
amount int,
unit_price decimal(12, 4),
total_price decimal(12, 4),
description varchar(2000),
ts timestamp default now(),
deal bool default false
);
```
查询 2022 年 5 月 25 日下单的所有单价低于 20 的订单id,那么这个查询应该如何写?
## 答案
```
mysql
select id
from orders
where date(ts) = '2022-05-25'
and unit_prise < 20;
```
## 选项
### A
```
mysql
select id
from (select * from orders where date(ts) = '2022-05-25') as o
where unit_prise < 20;
```
### B
```
mysql
select id
from orders
where date(ts) = '2022-05-25'
or unit_prise < 20;
```
### C
```
mysql
select id
from orders
if date(ts) = '2022-05-25' or unit_prise < 20;
```
### D
```
mysql
select id
from orders
which date(ts) = '2022-05-25'
or unit_prise < 20;
```
data/1.MySQL初阶/6.数据查询/3.运算符/config.json
浏览文件 @
2de7db37
{
"node_id"
:
"mysql-8f2aac71ea494f1b84372d43aa436135"
,
"keywords"
:
[],
"keywords"
:
[
"operator"
,
"运算符"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"geo.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
...
...
data/1.MySQL初阶/6.数据查询/3.运算符/geo.json
0 → 100644
浏览文件 @
2de7db37
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"geo.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"09df5b5537d340fab861362b9123fbfd"
}
\ No newline at end of file
data/1.MySQL初阶/6.数据查询/3.运算符/geo.md
0 → 100644
浏览文件 @
2de7db37
# 数值计算
Points 表结构如下:
```
mysql
create table points(
id int primary key auto_increment,
x float,
y float
)
```
现在 Joe 想要求写一个查询,得到每个点的id和模。即 √(x^2+y^2) 。这个查询应该是:
## 答案
```
mysql
select id, sqrt(x^2 + y^2) from points;
```
## 选项
### A
```
mysql
select sqrt(vx+vy) from (select x^2 as vx, y^2 as vy from points) as t;
```
### B
```
mysql
select sqrt(vx + vy) from points where x^2 as vx, y^2 as vy ;
```
### C
```
mysql
select id + sqrt(x^2 + y^2) from points;
```
### D
```
mysql
select id || sqrt(x^2 + y^2) from points;
```
\ No newline at end of file
gears/sql/goods.sql
0 → 100644
浏览文件 @
2de7db37
create
table
goods
(
id
int
primary
key
auto_increment
,
category_id
int
,
category
varchar
(
64
),
name
varchar
(
256
),
price
decimal
(
12
,
4
),
stock
int
,
upper_time
timestamp
)
\ No newline at end of file
gears/sql/orders.sql
0 → 100644
浏览文件 @
2de7db37
create
table
orders
(
id
int
primary
key
auto_increment
,
item_id
int
,
amount
int
,
unit_price
decimal
(
12
,
4
),
total_price
decimal
(
12
,
4
),
description
varchar
(
2000
),
ts
timestamp
default
now
(),
deal
bool
default
false
);
\ No newline at end of file
gears/sql/points.sql
0 → 100644
浏览文件 @
2de7db37
create
table
points
(
id
int
primary
key
auto_increment
,
x
float
,
y
float
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录