diff --git "a/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/datetime.json" "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/datetime.json" new file mode 100644 index 0000000000000000000000000000000000000000..ce14a1923a0818b3654d858fa08f86127fec1a7f --- /dev/null +++ "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/datetime.json" @@ -0,0 +1,7 @@ +{ + "type": "code_options", + "author": "ccat", + "source": "datetime.md", + "notebook_enable": false, + "exercise_id": "89e67a85e4144bea88aded6e4dd280c2" +} \ No newline at end of file diff --git "a/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/datetime.md" "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/datetime.md" new file mode 100644 index 0000000000000000000000000000000000000000..4152a515bf54e6c0c27869954b089855253de5fb --- /dev/null +++ "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/datetime.md" @@ -0,0 +1,82 @@ +# 时间默认值 + +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() +); +``` diff --git "a/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/description.json" "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/description.json" new file mode 100644 index 0000000000000000000000000000000000000000..08d4321b0b21b263b128022f6a7bcf82a89bc342 --- /dev/null +++ "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/description.json" @@ -0,0 +1,7 @@ +{ + "type": "code_options", + "author": "ccat", + "source": "description.md", + "notebook_enable": false, + "exercise_id": "deb54053952b41b894e244277a9c1acf" +} \ No newline at end of file diff --git "a/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/description.md" "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/description.md" new file mode 100644 index 0000000000000000000000000000000000000000..d6a6033a579c2b92d1f2d8275db7deaf712f26c6 --- /dev/null +++ "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/description.md" @@ -0,0 +1,88 @@ +# 文本字段 + +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 diff --git "a/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/numbers.md" "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/numbers.md" new file mode 100644 index 0000000000000000000000000000000000000000..31be887bb60bd9150e6da69b28b74a2e178d4d8d --- /dev/null +++ "b/data/1.PostgreSQL\345\210\235\351\230\266/3.\346\237\245\350\257\242\346\225\260\346\215\256/4.\345\270\270\350\247\201\346\225\260\346\215\256\347\261\273\345\236\213/numbers.md" @@ -0,0 +1,45 @@ +# 数值的隐式类型转换 + +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 diff --git "a/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/config.json" "b/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/config.json" index b9b3c61bffadc15fea4eb69b4828c996d242dd03..4b2fa42b501a5aa283caac56711f876748a93b7b 100644 --- "a/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/config.json" +++ "b/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/config.json" @@ -1,17 +1,15 @@ { "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 diff --git "a/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/distribute.json" "b/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/distribute.json" new file mode 100644 index 0000000000000000000000000000000000000000..fced6d89be0b13d89f1333b60f3bd44e65c87eff --- /dev/null +++ "b/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/distribute.json" @@ -0,0 +1,7 @@ +{ + "type": "code_options", + "author": "ccat", + "source": "distribute.md", + "notebook_enable": false, + "exercise_id": "9b4da19d895e4761a8946b0922693e38" +} \ No newline at end of file diff --git "a/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/distribute.md" "b/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/distribute.md" new file mode 100644 index 0000000000000000000000000000000000000000..4b62bcf88e03f86c4f8e7955fbddfcefcafde305 --- /dev/null +++ "b/data/3.PostgreSQL\351\253\230\351\230\266/3.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/distribute.md" @@ -0,0 +1,31 @@ +# 分布函数 + +关于分布函数,以下说法正确的是 + +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 + +全都不对 diff --git "a/data/3.PostgreSQL\351\253\230\351\230\266/4.\350\277\233\351\230\266\344\273\273\345\212\241/1.\346\225\260\346\215\256\345\272\223\351\227\256\347\255\224/qa.json" "b/data/3.PostgreSQL\351\253\230\351\230\266/4.\350\277\233\351\230\266\344\273\273\345\212\241/1.\346\225\260\346\215\256\345\272\223\351\227\256\347\255\224/qa.json" index 989a85d32a3dfead74effc8e263a47103979c5ab..982172cb5d3d7fe192466c72479dace5dc34e2b0 100644 --- "a/data/3.PostgreSQL\351\253\230\351\230\266/4.\350\277\233\351\230\266\344\273\273\345\212\241/1.\346\225\260\346\215\256\345\272\223\351\227\256\347\255\224/qa.json" +++ "b/data/3.PostgreSQL\351\253\230\351\230\266/4.\350\277\233\351\230\266\344\273\273\345\212\241/1.\346\225\260\346\215\256\345\272\223\351\227\256\347\255\224/qa.json" @@ -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, diff --git a/data/tree.json b/data/tree.json index d360e548d70cf0241162a321509bdaf333e3823c..51372b9b1dfa022ede8dee3d059db7c4843c2255 100644 --- a/data/tree.json +++ b/data/tree.json @@ -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