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"
:
[
"函数"
,
"function"
"window function"
],
"children"
:
[],
"node_id"
:
"pg-cab66a558cda467eabd9587b5a8257bd"
,
"export"
:
[
"salary.json"
"salary.json"
,
"distribute.json"
],
"keywords_must"
:
[
"函数"
,
"function"
,
"window"
"window function"
],
"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 @@
"depends"
:
[],
"type"
:
"qa_task"
,
"task_link"
:
"https://ask.csdn.net/channel/20/tag/300001"
,
"task_info"
:{
"task_info"
:
{
"tag_name"
:
"数据库"
},
"notebook_enable"
:
false
,
...
...
data/tree.json
浏览文件 @
68af5052
...
...
@@ -29,8 +29,7 @@
"relational"
,
"rdbms"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -47,14 +46,12 @@
"服务器"
,
"客户端"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -73,8 +70,7 @@
"keywords_must"
:
[
"安装"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -89,8 +85,7 @@
"keywords_must"
:
[
"登录"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -106,14 +101,12 @@
"基本用法"
,
"入门"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -133,8 +126,7 @@
"keywords_must"
:
[
"psql"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -149,8 +141,7 @@
"语法"
,
"SQL"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -170,20 +161,35 @@
"update"
,
"delete"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
"常见数据类型"
:
{
"node_id"
:
"pg-3c400d541e81472e842be3355978c33a"
,
"keywords"
:
[
"datetime"
,
"text"
,
"varchar"
,
"int"
,
"double"
,
"float"
,
"decimal"
,
"timestamp"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -208,8 +214,7 @@
"表"
,
"table"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -224,8 +229,7 @@
"函数"
,
"function"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -250,8 +254,7 @@
"权限"
,
"privilege"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -270,8 +273,7 @@
"constraints"
,
"index"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -286,8 +288,7 @@
"trigger"
,
"触发器"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -303,14 +304,12 @@
"数据库扩展"
,
"extension"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -331,8 +330,7 @@
"分组"
,
"聚合"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -347,8 +345,7 @@
"join"
,
"连接查询"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -363,8 +360,7 @@
"子查询"
,
"subquery"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -381,8 +377,7 @@
"limit"
,
"offset"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -397,8 +392,7 @@
"keywords_must"
:
[
"cte"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -412,8 +406,7 @@
"keywords_must"
:
[
"过程化"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -430,20 +423,17 @@
"授权"
,
"ddl"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -469,8 +459,7 @@
"keywords_must"
:
[
"standby"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -487,8 +476,7 @@
"流式复制"
,
"流复制"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -503,14 +491,12 @@
"外部数据连接"
,
"fdw"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -530,8 +516,7 @@
"gis"
,
"几何"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -546,8 +531,7 @@
"json"
,
"jsonb"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -569,8 +553,7 @@
],
""
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -585,14 +568,12 @@
"视图"
,
"view"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -614,25 +595,20 @@
"递归查询"
,
"recursive"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
"Window Function"
:
{
"node_id"
:
"pg-cab66a558cda467eabd9587b5a8257bd"
,
"keywords"
:
[
"函数"
,
"function"
"window function"
],
"children"
:
[],
"keywords_must"
:
[
"函数"
,
"function"
,
"window"
"window function"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -649,8 +625,7 @@
"交叉透视表"
,
"pivot"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -666,8 +641,7 @@
"conflict"
,
"冲突"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -682,8 +656,7 @@
"事务"
,
"transaction"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -702,14 +675,12 @@
"performance"
,
"优化"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
},
{
...
...
@@ -727,25 +698,21 @@
"keywords_must"
:
[
"数据库问答"
],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"keywords_forbid"
:
[]
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录