提交 7e2cfb8f 编写于 作者: M Mars Liu

on tree

上级 60b9147a
{
"node_id": "mysql-764d5080ddb943fe9236922984afa152",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-d2cdd250a5f24c8e9676e0fa1faf5772",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-98e926730d844f238dc9cd8ac5f65126",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-88c53ba3b31f4ae5a4de3809d61cf539",
"keywords": [
"数据库扩展",
"数据库插件",
"extension"
],
"children": [],
"export": [
"language.json",
"extension.json"
],
"keywords_must": [
"数据库扩展",
"extension"
],
"keywords_forbid": []
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "extension.md",
"notebook_enable": false,
"exercise_id": "8875ecad1e9f403bbad6f68f2f5d6a9f"
}
\ No newline at end of file
# 外部扩展
下列哪个功能需要通过`create exension`语句安装扩展得到?
## 答案
postgis
## 选项
### A
全文检索
### B
JSONB
### C
GIST 和 GIN 索引
### D
JSON Path 支持
### E
XML 和 XSLT 支持
### F
面向对象语法
{
"type": "code_options",
"author": "ccat",
"source": "language.md",
"notebook_enable": false,
"exercise_id": "1d88714991c849c7ad65b9b4fa17c583"
}
\ No newline at end of file
# 过程语言
关于 PostgreSQL PL 语言,错误的是:
## 答案
要安装新的扩展语言,需要重新编译 PostgreSQL 内核。
## 选项
### A
PG 可以支持 Python、Perl、Lua 等多种 PL 语言编写函数。
### B
通过 create language 可以安装新的 pl 语言支持
### C
实现新的 PL 语言需要遵循 PostgreSQL 的语言扩展规范。
### D
用外部语言实现函数,要考虑跨边界传递数据的开销
\ No newline at end of file
{
"node_id": "mysql-af89d54d66974111b4f67aeba2af7161",
"keywords": [],
"children": [],
"export": []
}
\ No newline at end of file
{
"node_id": "mysql-af89d54d66974111b4f67aeba2af7161",
"keywords": [],
"children": [],
"export": [],
"keywords_must": []
}
\ No newline at end of file
{
"node_id": "mysql-2296dbe96d584a52bd28a3ad5f655518",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-8e6cd4d5f4b446a2bc3f5402de9bd49c",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-153ce0dadc824af98de199f193c8c75c",
"keywords": ["distinct"],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-fa20a81805b44975aed265dd058c542a",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-b57b6c08f5f240c6a997284e4448f088",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-64454fb14452475a8c3b348bf4d840cc",
"node_id": "mysql-ed0a3aa2ca704780ae72749842657fa7",
"keywords": [],
"keywords_must": [],
"keywords_forbid": []
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-a69988041f934af1af39f2da4b3e0d58",
"keywords": [
"common table expression",
"cte",
"recursive"
],
"children": [],
"export": [
"to_root.json"
],
"keywords_must": [
"cte"
],
"keywords_forbid": []
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "to_root.md",
"notebook_enable": false,
"exercise_id": "3d631bd0b26b44b4a8951ef7d4f865ec"
}
\ No newline at end of file
# 树结构溯根
现有一个表 node
```postgresql
create table node
(
id serial primary key,
pid integer,
content text
);
```
其 pid 列引用 id 列,形成一个树结构,根节点的 pid 为 0。
现在我们希望写一个查询,找到某一个给定id的记录,其父节点、父节点的父节点,直至根节点的路径。那么这个查询应该是:
## 答案
```postgresql
with recursive t(id, pid, content) as (
select id, pid, content
from node
where id = $1
union all
select node.id, node.pid, node.content
from node
join t on node.id = t.pid)
select node.id, node.pid, content
from node
join t on node.id = t.id;
```
## 选项
### 没有递归定义
```postgresql
with t as (
select id, pid, content
from node
where id = $1
union all
select node.id, node.pid, node.level
from node
join t on node.id = t.pid)
select node.id, node.pid, content
from node
join t on node.id = t.id;
```
### 平凡的连接查询无法处理递归问题
```postgresql
select node.id, node.pid, node.content
from node
join node as p on node.pid = p.id
where id = $1;
```
### 子查询无法处理递归问题
```postgresql
select node.id, node.pid, node content
from node as t
where t.pid = (select id from t where id = t.pid)
```
\ No newline at end of file
{
"node_id": "mysql-7b3a382e0cdb4f089fb3b1769c91025f",
"keywords": [
"plsql",
"过程化"
],
"children": [],
"export": [
"loop.json"
],
"keywords_must": [
"过程化"
],
"keywords_forbid": []
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "loop.md",
"notebook_enable": false,
"exercise_id": "4f53e1f2bc704c7fbe4b2586d690d3ff"
}
\ No newline at end of file
# 循环
下面哪一项定义的函数可以生成指定范围内的整数数列?
## 答案
```postgresql
create function gen(start integer, stop integer)
returns setof integer as
$$
begin
for idx in start .. stop
loop
return next idx;
end loop;
end;
$$ language plpgsql;
```
## 选项
### A
```postgresql
create function gen(start integer, stop integer) returns integer as
$$
begin
for idx in start .. stop
loop
return idx;
end loop;
end;
$$ language plpgsql;
```
### B
```postgresql
create function gen(start integer, stop integer)
returns integer as
$$
begin
for idx in start .. stop
loop
yield idx;
end loop;
end;
$$ language plpgsql;
```
### C
```postgresql
create function gen(start integer, stop integer)
returns setof integer as
$$
begin
for idx in start .. stop
loop
return idx;
idx += 1;
end loop;
end;
$$ language plpgsql;
```
### D
```postgresql
create function gen(start integer, stop integer)
returns setof integer as
$$
begin
for idx in start .. stop
loop
select idx;
end loop;
end;
$$ language plpgsql;
```
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "analyze.md",
"notebook_enable": false,
"exercise_id": "df45f27112f7405888a5ee7e18d78b87"
}
\ No newline at end of file
# 建表权限
SmartMarket 公司有一百名分析师,他们都属于 analyst 团队,现在他们希望能够在 market 仓库的 ana schema 下
自由的建表和删除表,以便进行模型试验。下列操作步骤中需要选择哪几项?(ana schema 和分析师的团队角色还不存在)
1. `create schema ana`
2. `create role analyst`
3. `grant create, usage on schema ana to analyst`
4. 将 analyst 角色授予每个分析师的账号
5. 删除 public schema
6. `grant superuser on schema ana to analyst`
7. `grant owner on schema ana to analyst;`
## 答案
1,2, 3, 4
## 选项
### A
所有全部
### B
1, 2, 5, 6, 7
### C
1, 2, 6, 7
### D
1, 2, 3, 6, 7
### E
2, 3, 4, 5
\ No newline at end of file
{
"node_id": "mysql-2bd968a23ccb4668b853421206b46eeb",
"keywords": [
"创建表",
"授权",
"ddl"
],
"children": [],
"export": [
"create_table.json",
"analyze.json"
],
"keywords_must": [
"创建表",
"授权",
"ddl"
],
"keywords_forbid": []
}
\ No newline at end of file
{
"type": "code_options",
"author": "ccat",
"source": "create_table.md",
"notebook_enable": false,
"exercise_id": "d6e788dd034b4e0093b8ca39a8dd6b6b"
}
\ No newline at end of file
# 创建表
下列方法中,可以创建表的有:
1. 使用 `create table xxx();`语句
2. 使用 `copy` 语句从 csv 导入数据
3. 使用 `create table as select...` 语句从查询中创建表
## 答案
1, 3
## 选项
### A
1, 2, 3
### B
1, 2
### C
2, 3
### D
只有 1
\ No newline at end of file
{
"node_id": "mysql-ac3c072bc54749bdb82324f2b203890d",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-c5654c150993418a96f692496837fbb7",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-c1652108441c424197c0c3c526e4831c",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-77042376726743bea5c97e82a67a2016",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-11462fccf9d24d17a372d5c60af90f54",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-3b85e53dd88146798d21b7254ad85cae",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-91829d4938034ce09e99badf23dbebf6",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-73bfbd883511436c85130b71fa108038",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-d7a8869fb798498c839c913ce930015d",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-7c2331eea3e84eef9464ad4d7c03e2de",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-fd27af20b046463eac7b2712885ac018",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
}
\ No newline at end of file
{
"node_id": "mysql-a4773004e0cf432aa7ccdf6b9490838f",
"keywords": [],
"children": [],
"export": [],
"keywords_must": [],
"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.
先完成此消息的编辑!
想要评论请 注册