提交 a796fb05 编写于 作者: M Mars Liu

fixed odd orders

上级 577d8251
{
"node_id": "pg-6920a4f2ba864459bd8883a7a48fa238",
"node_id": "pg-11d131b2d01b40be90b23f096d4852cc",
"keywords": [],
"children": [],
"export": ["relation.json"]
"export": [
"relation.json"
]
}
\ No newline at end of file
{
"type": "code_options",
"author": "刘鑫",
"source": "relation.md",
"notebook_enable": false,
"exercise_id": "e50c1cee116d4054b9794c57effa9f5a"
}
\ No newline at end of file
......@@ -2,5 +2,6 @@
"type": "code_options",
"author": "刘鑫",
"source": "client.md",
"notebook_enable": false
"notebook_enable": false,
"exercise_id": "88b033cd97c642ef9900e5e091e335ff"
}
\ No newline at end of file
{
"node_id": "pg-40374311856c4ad3b76fff16ecbe9dce",
"node_id": "pg-cf0e5cb243a247e2a0b812c5798cdba4",
"keywords": [],
"children": [],
"export": ["client.json", "server.json"]
"export": [
"client.json",
"server.json"
]
}
\ No newline at end of file
{
"node_id": "pg-b710bd5c63fb4651bebfdd9b3fdb17a5",
"node_id": "pg-1aad17890736469a8b2f61a36dfe41db",
"keywords": []
}
\ No newline at end of file
{
"node_id": "pg-c252ff4b0e7f4163837c9b6f81678505",
"keywords": [],
"keywords": ["login", "connect"],
"children": [],
"export": []
"export": ["develop.json"]
}
\ No newline at end of file
{
"type": "code_options",
"author": "刘鑫",
"source": "develop.md",
"notebook_enable": false
}
\ No newline at end of file
# 开发环境中的 PostgreSQL
你是 SmartMarket 公司的一名开发人员,公司使用 Linux 运行 PostgreSQL 服务,而你的开发机使用 MacOS。下列说法正确的是:
1. 在 MacOS 上,使用 Homebrew 安装 PostgreSQL 后,在当前用户下执行 psql postgres 可以登入数据库
2. 在 Linux 上,使用 yum 或 apt 安装 PostgreSQL 后,sudo su postgres 切换到 postgres 用户,可以执行 psql 登入数据库
3. 对于自己安装的数据库服务器(非RDS),如果需要开放远程登录,需要编辑数据目录下的 postgresql.conf 和 pg_hua.conf
4. 安装 PostgreSQL 前,需要重装系统以获得一个干净的内核环境
5. 安装 PostgreSQL 前,需要手工建立一个名为 postgres 的超级用户
6. 安装 PostgreSQL 需要先安装 gcc 或 llvm clang
7. 对于使用 linux 的开发者,通常需要安装 postgresql 的开发包,这通常可以在主流的 linux 发行版的软件服务中找到,一般叫 postgresql-devel 或 postgresql-dev
## 答案
1, 2, 3, 7
## 选项
### A
1, 2, 3, 4, 5, 6, 7
### B
1, 2, 3
### C
2, 3, 4, 5
### D
5, 6, 7
### E
1, 3, 5, 7
### F
2, 4, 6
{
"node_id": "pg-3ac4a2bf31af423fb9e2ec9fe30024c5",
"node_id": "pg-d95edf2d942b45d781e112be785ce260",
"keywords": []
}
\ No newline at end of file
{
"type": "code_options",
"author": "刘鑫",
"source": "basic.md",
"notebook_enable": false
}
\ No newline at end of file
# 基本语法
下列 SQL 语句,哪一项不合法?
## 答案
```postgresql
from test select abc;
```
## 选项
### A
```postgresql
select 3.14;
```
### B
```postgresql
select * from employee;
```
### C
```postgresql
select * from employee where dept = 'hr';
```
### D
```postgresql
select id, name, dept, salary from employee where salary > 10000::money;
```
### E
```postgresql
select now();
```
{
"node_id": "pg-dca8da7637f94ded91a1871daa51746e",
"keywords": [],
"keywords": ["语法", "select"],
"children": [],
"export": []
"export": ["basic.json"]
}
\ No newline at end of file
# 基本概念
下列叙述中,正确的是
1. 带有 select 关键字的查询不会修改数据
2. 查询表需要 select 权限
3. 修改一个数据库表或对象的结构,通常语句中会出现 create、add、drop、alter 等关键字
4. 修改数据内容,通常会出现update、insert、delete等关键字
5. update、insert、delete可以单独授权
## 答案
2, 3, 4, 5
## 选项
### A
1, 2, 3, 4, 5
### B
4, 5
### C
1, 2, 3
### D
3, 4, 5
\ No newline at end of file
{
"node_id": "pg-b0f366abe12e41b0a9672d317e556662",
"keywords": [],
"keywords": ["DML", "insert", "update", "delete"],
"children": [],
"export": []
"export": [
"insert.json",
"update.json",
"delete.json",
"concept.json"
]
}
\ No newline at end of file
{
"node_id": "pg-1eae8a80615f436081e71b36d89fb0aa",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "pg-ebef9fceb3684b119a9ba221a81f304b",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "pg-7e2e52dbddb44d5bad6deea6c5e57198",
"node_id": "pg-30f905f73a574151994d6d7f58d8a20d",
"keywords": []
}
\ No newline at end of file
{
"node_id": "pg-6089aef54c4c4ce7bc85b4dfa14f44cd",
"node_id": "pg-f1c160affc45417a9c5fff7dc4be448a",
"keywords": []
}
\ No newline at end of file
{
"node_id": "pg-e1cd59819dd74a0bacc707f7863aad53",
"keywords": [],
"children": [],
"export": ["insert.json", "update.json", "delete.json"]
}
\ No newline at end of file
{
"node_id": "pg-c360138dad92431594130596c5c91394",
"node_id": "pg-fc32585f4136497ea9be2d057d4aeada",
"keywords": []
}
\ No newline at end of file
{
"node_id": "pg-ec4bbb39e76949b48b13f04cc8c16532",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
# 去重
下列函数中,有一个实现了合并两个 jsonb 对象并对其去重,是哪一项?
## 答案
```postgresql
create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as
$$
select jsonb_agg(distinct (value)) from jsonb_array_elements(a || b)
$$ language sql
```
## 选项
### A
```postgresql
create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$
select a || b
$$ language sql
```
### B
```postgresql
create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$
return jsonb_agg(distinct(value)) from jsonb_array_elements(a||b)
$$ language sql
```
### C
```postgresql
create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$
return next jsonb_agg(distinct(value)) from jsonb_array_elements(a||b)
$$ language sql
```
### D
```postgresql
create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$
select a + b;
$$ language sql
```
\ No newline at end of file
# 视图
SmartMarket 公司的数据分析师,每天要执行一个固定的复杂查询,生成每日报表。我们准备将其创建为视图,这能够解决:
1. 简化查询
2. 降低查询时死锁的风险
3. 大幅优化查询性能
4. 限制权限
## 答案
1, 4
## 选项
### A
1. 2, 3, 4
### B
1, 2, 3
### C
2, 3
### D
3, 4
\ No newline at end of file
{
"node_id": "pg-e4b00736ab4c483785c022a0a464f30a",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "pg-0e280b203b524a28ab8587aac125a865",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "pg-2f46da8212cf41ad9c0d2a5bf1330adc",
"node_id": "pg-c9c7629c52064d8780cbd4dc14dbe351",
"keywords": []
}
\ No newline at end of file
{
"tree_name": "pg",
"keywords": [],
"node_id": "pg-4544619de2a54841930282c700ba92b8"
"node_id": "pg-d8b0b9aded4c4cc0b2085d6a7c5611c7"
}
\ No newline at end of file
......@@ -249,7 +249,7 @@ class TreeWalker:
def ensure_node_id(self, config):
flag = False
if "node_id" not in config or \
not config["node_id"].startswith(f"{self.tree}-") or \
not config["node_id"].startswith(f"{self.name}-") or \
config["node_id"] in id_set:
new_id = self.gen_node_id()
id_set.add(new_id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册