Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_pg
提交
68af5052
S
skill_tree_pg
项目概览
CSDN 技术社区
/
skill_tree_pg
通知
9
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_pg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
68af5052
编写于
6月 22, 2022
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add window function excerise
上级
92a0b9a1
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
345 addition
and
108 deletion
+345
-108
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/datetime.json
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/datetime.json
+8
-0
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/datetime.md
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/datetime.md
+82
-0
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/description.json
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/description.json
+8
-0
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/description.md
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/description.md
+89
-0
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/numbers.md
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/numbers.md
+45
-0
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/config.json
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/config.json
+5
-6
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/distribute.json
....PostgreSQL高阶/3.SQL高级技巧/2.Window Function/distribute.json
+8
-0
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/distribute.md
.../3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/distribute.md
+31
-0
data/3.PostgreSQL高阶/4.进阶任务/1.数据库问答/qa.json
data/3.PostgreSQL高阶/4.进阶任务/1.数据库问答/qa.json
+1
-1
data/tree.json
data/tree.json
+68
-101
未找到文件。
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/datetime.json
0 → 100644
浏览文件 @
68af5052
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"datetime.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"89e67a85e4144bea88aded6e4dd280c2"
}
\ No newline at end of file
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/datetime.md
0 → 100644
浏览文件 @
68af5052
# 时间默认值
Joe 写了一个订单表的创建语句:
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money
);
```
现在,Joe 需要给这个表加入下单时间,即订单写入数据库的时间,那么他应该将这个语句修改为:
## 答案
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
ts timestamp default now()
);
```
## 选项
### A
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
ts varchar(16) default now()
);
```
### B
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
ts varchar(16) format 'yyyy-mm-dd'
);
```
### C
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
ts date default now()
);
```
### D
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
ts datetime default now()
);
```
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/description.json
0 → 100644
浏览文件 @
68af5052
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"description.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"deb54053952b41b894e244277a9c1acf"
}
\ No newline at end of file
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/description.md
0 → 100644
浏览文件 @
68af5052
# 文本字段
Joe 在设计订单表,他已经完成了下列内容:
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
ts timestamp default now()
);
```
现在他需要给订单表加入一个 description 字段,这个字段需要保存订单的文字说明,这些文本不会超过两千字节, Joe 应该把建表语句修改为:
## 答案
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
description text,
ts timestamp default now()
);
```
## 选项
### A
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
description char(2000),
ts timestamp default now()
);
```
### B
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
description varchar(256) default '',
ts timestamp default now()
);
```
### C
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
description text(2000),
ts timestamp default now()
);
```
### D
```
postgresql
create table orders (
id serial primary key,
item_id int,
amount int,
unit_price money,
price money,
description tinytext(2000),
ts timestamp default now()
);
```
\ No newline at end of file
data/1.PostgreSQL初阶/3.查询数据/4.常见数据类型/numbers.md
0 → 100644
浏览文件 @
68af5052
# 数值的隐式类型转换
Joe 需要使用下列表做一项数值计算
```
postgresql
create table points(
id serial primary key,
x int,
y int
);
```
计算查询为:
```
postgresql
select id, (x^2 + y^2)/2 as result from points;
```
得到的结果集中,result 列的类型应该是:
## 答案
double
## 选项
### A
float
### B
decimal
### C
int
### D
long
### E
byte
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/config.json
浏览文件 @
68af5052
{
{
"keywords"
:
[
"keywords"
:
[
"函数"
,
"window function"
"function"
],
],
"children"
:
[],
"children"
:
[],
"node_id"
:
"pg-cab66a558cda467eabd9587b5a8257bd"
,
"node_id"
:
"pg-cab66a558cda467eabd9587b5a8257bd"
,
"export"
:
[
"export"
:
[
"salary.json"
"salary.json"
,
"distribute.json"
],
],
"keywords_must"
:
[
"keywords_must"
:
[
"函数"
,
"window function"
"function"
,
"window"
],
],
"keywords_forbid"
:
[]
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/distribute.json
0 → 100644
浏览文件 @
68af5052
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"distribute.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"9b4da19d895e4761a8946b0922693e38"
}
\ No newline at end of file
data/3.PostgreSQL高阶/3.SQL高级技巧/2.Window Function/distribute.md
0 → 100644
浏览文件 @
68af5052
# 分布函数
关于分布函数,以下说法正确的是
1.
`PERCENT_RANK()`
函数是等级值百分比函数。
2.
`CUME_DIST()`
函数主要用于查询小于或等于某个值的比例
(number of partition rows preceding or peers with current row) / (total partition rows)
3.
`PERCENT_RANK() `
按照
` (rank - 1) / (total partition rows - 1)`
计算, 其中,
rank 的值为使用RANK()函数产生的序号,rows的值为当前窗口的总记录数。
## 答案
全部都对
## 选项
### A
```
1, 2
```
### B
```
2, 3
```
### C
全都不对
data/3.PostgreSQL高阶/4.进阶任务/1.数据库问答/qa.json
浏览文件 @
68af5052
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
"depends"
:
[],
"depends"
:
[],
"type"
:
"qa_task"
,
"type"
:
"qa_task"
,
"task_link"
:
"https://ask.csdn.net/channel/20/tag/300001"
,
"task_link"
:
"https://ask.csdn.net/channel/20/tag/300001"
,
"task_info"
:{
"task_info"
:
{
"tag_name"
:
"数据库"
"tag_name"
:
"数据库"
},
},
"notebook_enable"
:
false
,
"notebook_enable"
:
false
,
...
...
data/tree.json
浏览文件 @
68af5052
...
@@ -29,8 +29,7 @@
...
@@ -29,8 +29,7 @@
"relational"
,
"relational"
,
"rdbms"
"rdbms"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -47,14 +46,12 @@
...
@@ -47,14 +46,12 @@
"服务器"
,
"服务器"
,
"客户端"
"客户端"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -73,8 +70,7 @@
...
@@ -73,8 +70,7 @@
"keywords_must"
:
[
"keywords_must"
:
[
"安装"
"安装"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -89,8 +85,7 @@
...
@@ -89,8 +85,7 @@
"keywords_must"
:
[
"keywords_must"
:
[
"登录"
"登录"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -106,14 +101,12 @@
...
@@ -106,14 +101,12 @@
"基本用法"
,
"基本用法"
,
"入门"
"入门"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -133,8 +126,7 @@
...
@@ -133,8 +126,7 @@
"keywords_must"
:
[
"keywords_must"
:
[
"psql"
"psql"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -149,8 +141,7 @@
...
@@ -149,8 +141,7 @@
"语法"
,
"语法"
,
"SQL"
"SQL"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -170,20 +161,35 @@
...
@@ -170,20 +161,35 @@
"update"
,
"update"
,
"delete"
"delete"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
},
{
"常见数据类型"
:
{
"node_id"
:
"pg-3c400d541e81472e842be3355978c33a"
,
"keywords"
:
[
"datetime"
,
"text"
,
"varchar"
,
"int"
,
"double"
,
"float"
,
"decimal"
,
"timestamp"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -208,8 +214,7 @@
...
@@ -208,8 +214,7 @@
"表"
,
"表"
,
"table"
"table"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -224,8 +229,7 @@
...
@@ -224,8 +229,7 @@
"函数"
,
"函数"
,
"function"
"function"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -250,8 +254,7 @@
...
@@ -250,8 +254,7 @@
"权限"
,
"权限"
,
"privilege"
"privilege"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -270,8 +273,7 @@
...
@@ -270,8 +273,7 @@
"constraints"
,
"constraints"
,
"index"
"index"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -286,8 +288,7 @@
...
@@ -286,8 +288,7 @@
"trigger"
,
"trigger"
,
"触发器"
"触发器"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -303,14 +304,12 @@
...
@@ -303,14 +304,12 @@
"数据库扩展"
,
"数据库扩展"
,
"extension"
"extension"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -331,8 +330,7 @@
...
@@ -331,8 +330,7 @@
"分组"
,
"分组"
,
"聚合"
"聚合"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -347,8 +345,7 @@
...
@@ -347,8 +345,7 @@
"join"
,
"join"
,
"连接查询"
"连接查询"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -363,8 +360,7 @@
...
@@ -363,8 +360,7 @@
"子查询"
,
"子查询"
,
"subquery"
"subquery"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -381,8 +377,7 @@
...
@@ -381,8 +377,7 @@
"limit"
,
"limit"
,
"offset"
"offset"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -397,8 +392,7 @@
...
@@ -397,8 +392,7 @@
"keywords_must"
:
[
"keywords_must"
:
[
"cte"
"cte"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -412,8 +406,7 @@
...
@@ -412,8 +406,7 @@
"keywords_must"
:
[
"keywords_must"
:
[
"过程化"
"过程化"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -430,20 +423,17 @@
...
@@ -430,20 +423,17 @@
"授权"
,
"授权"
,
"ddl"
"ddl"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -469,8 +459,7 @@
...
@@ -469,8 +459,7 @@
"keywords_must"
:
[
"keywords_must"
:
[
"standby"
"standby"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -487,8 +476,7 @@
...
@@ -487,8 +476,7 @@
"流式复制"
,
"流式复制"
,
"流复制"
"流复制"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -503,14 +491,12 @@
...
@@ -503,14 +491,12 @@
"外部数据连接"
,
"外部数据连接"
,
"fdw"
"fdw"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -530,8 +516,7 @@
...
@@ -530,8 +516,7 @@
"gis"
,
"gis"
,
"几何"
"几何"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -546,8 +531,7 @@
...
@@ -546,8 +531,7 @@
"json"
,
"json"
,
"jsonb"
"jsonb"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -569,8 +553,7 @@
...
@@ -569,8 +553,7 @@
],
],
""
""
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -585,14 +568,12 @@
...
@@ -585,14 +568,12 @@
"视图"
,
"视图"
,
"view"
"view"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -614,25 +595,20 @@
...
@@ -614,25 +595,20 @@
"递归查询"
,
"递归查询"
,
"recursive"
"recursive"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
"Window Function"
:
{
"Window Function"
:
{
"node_id"
:
"pg-cab66a558cda467eabd9587b5a8257bd"
,
"node_id"
:
"pg-cab66a558cda467eabd9587b5a8257bd"
,
"keywords"
:
[
"keywords"
:
[
"函数"
,
"window function"
"function"
],
],
"children"
:
[],
"children"
:
[],
"keywords_must"
:
[
"keywords_must"
:
[
"函数"
,
"window function"
"function"
,
"window"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -649,8 +625,7 @@
...
@@ -649,8 +625,7 @@
"交叉透视表"
,
"交叉透视表"
,
"pivot"
"pivot"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -666,8 +641,7 @@
...
@@ -666,8 +641,7 @@
"conflict"
,
"conflict"
,
"冲突"
"冲突"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -682,8 +656,7 @@
...
@@ -682,8 +656,7 @@
"事务"
,
"事务"
,
"transaction"
"transaction"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -702,14 +675,12 @@
...
@@ -702,14 +675,12 @@
"performance"
,
"performance"
,
"优化"
"优化"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
},
},
{
{
...
@@ -727,25 +698,21 @@
...
@@ -727,25 +698,21 @@
"keywords_must"
:
[
"keywords_must"
:
[
"数据库问答"
"数据库问答"
],
],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
],
],
"keywords_must"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"keywords_forbid"
:
[]
"group"
:
0
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录