diff --git a/content/zh/docs/Developerguide/Schema.md b/content/zh/docs/Developerguide/Schema.md index 2bf52f0e66bf851c89d12d4e9c7e1440b04117ad..b439b694181b99cc2b3a6ec17fbc1c1279c7c363 100644 --- a/content/zh/docs/Developerguide/Schema.md +++ b/content/zh/docs/Developerguide/Schema.md @@ -19,19 +19,19 @@ Schema又称作模式。通过管理Schema,允许多个用户使用同一数 - 要查看Schema所有者,请对系统表PG\_NAMESPACE和PG\_USER执行如下关联查询。语句中的schema\_name请替换为实际要查找的Schema名称。 ``` - postgres=# SELECT s.nspname,u.usename AS nspowner FROM pg_namespace s, pg_user u WHERE nspname='schema_name' AND s.nspowner = u.usesysid; + SELECT s.nspname,u.usename AS nspowner FROM pg_namespace s, pg_user u WHERE nspname='schema_name' AND s.nspowner = u.usesysid; ``` - 要查看所有Schema的列表,请查询PG\_NAMESPACE系统表。 ``` - postgres=# SELECT * FROM pg_namespace; + SELECT * FROM pg_namespace; ``` - 要查看属于某Schema下的表列表,请查询系统视图PG\_TABLES。例如,以下查询会返回Schema PG\_CATALOG中的表列表。 ``` - postgres=# SELECT distinct(tablename),schemaname from pg_tables where schemaname = 'pg_catalog'; + SELECT distinct(tablename),schemaname from pg_tables where schemaname = 'pg_catalog'; ``` diff --git "a/content/zh/docs/Developerguide/\344\273\216\350\277\231\351\207\214\345\274\200\345\247\213.md" "b/content/zh/docs/Developerguide/\344\273\216\350\277\231\351\207\214\345\274\200\345\247\213.md" index 653ab5c2f7e8d21d30d30bc16e05dbdb36efc276..18a705d4852b05ac9daa1be1a8c246d98674adeb 100644 --- "a/content/zh/docs/Developerguide/\344\273\216\350\277\231\351\207\214\345\274\200\345\247\213.md" +++ "b/content/zh/docs/Developerguide/\344\273\216\350\277\231\351\207\214\345\274\200\345\247\213.md" @@ -40,7 +40,7 @@ openGauss正常运行。 默认只有openGauss安装时创建的管理员用户可以访问初始数据库,您还可以创建其他数据库用户帐号。 ``` - postgres=# CREATE USER joe WITH PASSWORD "Bigdata@123"; + CREATE USER joe WITH PASSWORD "Bigdata@123"; ``` 当结果显示为如下信息,则表示创建成功。 @@ -56,7 +56,7 @@ openGauss正常运行。 4. 创建数据库。 ``` - postgres=# CREATE DATABASE db_tpcc OWNER joe; + CREATE DATABASE db_tpcc OWNER joe; ``` 当结果显示为如下信息,则表示创建成功。 diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE-LIKE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE-LIKE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" index 37aa3a978e13640d5f9f2026a77e348f4a5e54e0..cfad247693ef05f03838607bf0c81102678c3e56 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE-LIKE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE-LIKE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" @@ -7,25 +7,25 @@ 1. 使用CREATE TABLE LIKE语句创建表customer\_t的副本customer\_t\_copy。 ``` - postgres=# CREATE TABLE customer_t_copy (LIKE customer_t); + CREATE TABLE customer_t_copy (LIKE customer_t); ``` 2. 使用INSERT INTO…SELECT语句向副本填充原始表中的数据。 ``` - postgres=# INSERT INTO customer_t_copy (SELECT * FROM customer_t); + INSERT INTO customer_t_copy (SELECT * FROM customer_t); ``` 3. 删除原始表。 ``` - postgres=# DROP TABLE customer_t; + DROP TABLE customer_t; ``` 4. 使用ALTER TABLE语句将副本重命名为原始表名称。 ``` - postgres=# ALTER TABLE customer_t_copy RENAME TO customer_t; + ALTER TABLE customer_t_copy RENAME TO customer_t; ``` diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" index 62e3ffc2fe0c514d46debf466303cd39c9361659..af39843ca81431ce3790b1afa4d1e7b14b8b3462 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250CREATE-TABLE\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" @@ -11,7 +11,7 @@ 1. 使用CREATE TABLE语句创建表customer\_t的副本customer\_t\_copy。 ``` - postgres=# CREATE TABLE customer_t_copy + CREATE TABLE customer_t_copy ( c_customer_sk integer, c_customer_id char(5), c_first_name char(6), @@ -22,19 +22,19 @@ 2. 使用INSERT INTO…SELECT语句向副本填充原始表中的数据。 ``` - postgres=# INSERT INTO customer_t_copy (SELECT * FROM customer_t); + INSERT INTO customer_t_copy (SELECT * FROM customer_t); ``` 3. 删除原始表。 ``` - postgres=# DROP TABLE customer_t; + DROP TABLE customer_t; ``` 4. 使用ALTER TABLE语句将副本重命名为原始表名称。 ``` - postgres=# ALTER TABLE customer_t_copy RENAME TO customer_t; + ALTER TABLE customer_t_copy RENAME TO customer_t; ``` diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250DML\345\221\275\344\273\244\346\233\264\346\226\260\350\241\250.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250DML\345\221\275\344\273\244\346\233\264\346\226\260\350\241\250.md" index d935f39ae894a4d991ea913826d2f3323fcecd09..f76161aa020f052c11174334340779dccb6212bd 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250DML\345\221\275\344\273\244\346\233\264\346\226\260\350\241\250.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250DML\345\221\275\344\273\244\346\233\264\346\226\260\350\241\250.md" @@ -7,7 +7,7 @@ openGauss支持标准的数据库操作语言(DML)命令,对表进行更 假设存在表customer\_t,表结构如下: ``` -postgres=# CREATE TABLE customer_t +CREATE TABLE customer_t ( c_customer_sk integer, c_customer_id char(5), c_first_name char(6), @@ -21,13 +21,13 @@ postgres=# CREATE TABLE customer_t - 向表customer\_t中插入一行。 ``` - postgres=# INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES (3769, 5, 'Grace','White'); + INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES (3769, 5, 'Grace','White'); ``` - 向表customer\_t中插入多行数据。 ``` - postgres=# INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES + INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES (6885, 1, 'Joes', 'Hunter'), (4321, 2, 'Lily','Carter'), (9527, 3, 'James', 'Cook'), @@ -40,7 +40,7 @@ postgres=# CREATE TABLE customer_t - 使用UPDATE更新表中数据。修改字段c\_customer\_id值为0。 ``` - postgres=# UPDATE customer_t SET c_customer_id = 0; + UPDATE customer_t SET c_customer_id = 0; ``` 更多关于UPDATE的使用方法,请参见[UPDATE](UPDATE.md)。 @@ -50,7 +50,7 @@ postgres=# CREATE TABLE customer_t 可以使用WHERE子句指定需要删除的行,若不指定即删除表中所有的行,只保留数据结构。 ``` - postgres=# DELETE FROM customer_t WHERE c_last_name = 'Baker'; + DELETE FROM customer_t WHERE c_last_name = 'Baker'; ``` 更多关于DELETE的使用方法,请参见[DELETE](DELETE.md)。 @@ -58,7 +58,7 @@ postgres=# CREATE TABLE customer_t - 使用TRUNCATE命令快速从表中删除所有的行。 ``` - postgres=# TRUNCATE TABLE customer_t; + TRUNCATE TABLE customer_t; ``` 更多关于TRUNCATE的使用方法,请参见[TRUNCATE](TRUNCATE.md)。 diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\345\205\203\345\221\275\344\273\244\345\257\274\345\205\245\346\225\260\346\215\256.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\345\205\203\345\221\275\344\273\244\345\257\274\345\205\245\346\225\260\346\215\256.md" index 9439979037d697d3e93d1694777aab7c470d4993..4a3d323c7a3e786932c15e1d13c0c6bd85c86cf2 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\345\205\203\345\221\275\344\273\244\345\257\274\345\205\245\346\225\260\346\215\256.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\345\205\203\345\221\275\344\273\244\345\257\274\345\205\245\346\225\260\346\215\256.md" @@ -155,14 +155,14 @@ DWS的gsql工具提供了元命令\\copy进行数据导入。 1. 创建目标表a。 ``` - postgres=# CREATE TABLE a(a int); + CREATE TABLE a(a int); ``` 2. 导入数据。 1. 从stdin拷贝数据到目标表a。 ``` - postgres=# \copy a from stdin; + \copy a from stdin; ``` 出现\>\>符号提示时,输入数据,输入\\.时结束。 @@ -192,7 +192,7 @@ DWS的gsql工具提供了元命令\\copy进行数据导入。 - 在导入过程中,若数据源文件比外表定义的列数多,则忽略行尾多出来的列。 ``` - postgres=# \copy a FROM '/home/omm/2.csv' WITH (delimiter',',IGNORE_EXTRA_DATA 'on'); + \copy a FROM '/home/omm/2.csv' WITH (delimiter',',IGNORE_EXTRA_DATA 'on'); ``` diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\350\277\236\346\216\245.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\350\277\236\346\216\245.md" index f46d7e23bf883ee62a750a2cab698adf89dc5556..7ef0f1ed05ddb7031a7cbe8c22e158b30a75120d 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\350\277\236\346\216\245.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250gsql\350\277\236\346\216\245.md" @@ -42,13 +42,13 @@ gsql是openGauss提供的在命令行下运行的数据库连接工具。此工 3. 首次登录需要修改密码。原始密码为安装openGauss数据库手动输入的密码,具体请参见《安装指南》中”安装openGauss \> 执行安装”章节,此处需将原始密码修改为自定义的密码,例如Mypwd123,命令如下: ``` - postgres=# ALTER ROLE omm IDENTIFIED BY 'Mypwd123' REPLACE 'XuanYuan@2012'; + ALTER ROLE omm IDENTIFIED BY 'Mypwd123' REPLACE 'XuanYuan@2012'; ``` 4. 退出数据库。 ``` - postgres=# \q + \q ``` @@ -112,3 +112,4 @@ gsql是openGauss提供的在命令行下运行的数据库连接工具。此工 >- 禁止使用omm用户进行远程连接数据库。 + diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250\345\220\210\345\271\266\346\226\271\345\274\217\346\233\264\346\226\260\345\222\214\346\217\222\345\205\245\346\225\260\346\215\256.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250\345\220\210\345\271\266\346\226\271\345\274\217\346\233\264\346\226\260\345\222\214\346\217\222\345\205\245\346\225\260\346\215\256.md" index acc2db3493df7f01b7bb2c40bc3171c90e51fac8..51e113d3c557b9cd51354ee2d1d51b15dab0c6d7 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250\345\220\210\345\271\266\346\226\271\345\274\217\346\233\264\346\226\260\345\222\214\346\217\222\345\205\245\346\225\260\346\215\256.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250\345\220\210\345\271\266\346\226\271\345\274\217\346\233\264\346\226\260\345\222\214\346\217\222\345\205\245\346\225\260\346\215\256.md" @@ -46,7 +46,7 @@ MERGE INTO语句将目标表和源表中数据针对关联条件进行匹配, 3. 使用MERGE INTO 语句将源表products的数据合并至目标表newproducts。 ``` - postgres=# MERGE INTO newproducts np + MERGE INTO newproducts np USING products p ON (np.product_id = p.product_id ) WHEN MATCHED THEN @@ -123,7 +123,7 @@ MERGE INTO语句将目标表和源表中数据针对关联条件进行匹配, 4. 查询合并后的目标表newproducts。 ``` - postgres=# SELECT * FROM newproducts; + SELECT * FROM newproducts; ``` 返回信息如下: diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274-9.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274-9.md" index 1e426b92b7d914247c4368ff41491b3029cd255b..5226177cdff2d2713806d9d29b0df105ef5c2100 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274-9.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274-9.md" @@ -13,18 +13,25 @@ ## 使用步骤 -1. 用户进行数据库安全配置,并验证调优程序所在客户机能够正常访问到数据库实例所在的服务器; -2. 用户向数据库实例内倒入数据(如TPC-C, TPC-H),并根据调优程序所给出的示例代码,编写符合自己实际业务的benchmark(benchmark实例脚本路径在benchmark目录中).并手动验证benchmark可以正常跑通并可获得稳定的测试结果,记录下此时的测试结果,以方便后续对比调优效果; -3. 用户在确保数据库运行正常并在无其他人使用时,备份现有参数,并修改调优参数列表配置文件(文件路径在knobs目录中,默认配置文件是knobs\_htap.py),设定需要调整的参数及其范围; -4. 用户输入数据库连接信息,选择当前调优模式为“训练”或“调优”,启动参数调优程序;例如在X-Tuner根目录中输入 +1. 用户进行数据库安全配置,并验证调优程序所在客户机能够正常访问到数据库实例所在的服务器; - python main.py -m train --db-name postgres\\ +2. 用户向数据库实例内倒入数据(如TPC-C, TPC-H),并根据调优程序所给出的示例代码,编写符合自己实际业务的benchmark(benchmark实例脚本路径在benchmark目录中).并手动验证benchmark可以正常跑通并可获得稳定的测试结果,记录下此时的测试结果,以方便后续对比调优效果; - --db-user dba --port 1234 \\ +3. 用户在确保数据库运行正常并在无其他人使用时,备份现有参数,并修改调优参数列表配置文件(文件路径在knobs目录中,默认配置文件是knobs\_htap.py),设定需要调整的参数及其范围; - --host 192.168.1.2 --host-user opengauss\\ +4. 用户输入数据库连接信息,选择当前调优模式为“训练”或“调优”,启动参数调优程序;例如在X-Tuner根目录中输入 - --benchmark tpcc --model-path mymodel + ``` + python main.py -m train --db-name postgres\\ + + --db-user dba --port 1234 \\ + + --host 192.168.1.2 --host-user opengauss\\ + + --benchmark tpcc --model-path mymodel + ``` + + 5. 若为“训练”模式,则输出训练后的模型,程序退出;若为“调优”模式,则输出调优后的最优参数列表,程序退出。用户通过对比调优结果,自行判断是否应该设置为该参数,并手动设置为推荐参数或重置为调优前参数。 diff --git "a/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274.md" "b/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274.md" index b1b18b1ba84812a26b546177b8f32a1793eb70db..192ed1e48118e543beeece12f7bb2648de1299c4 100644 --- "a/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274.md" +++ "b/content/zh/docs/Developerguide/\344\275\277\347\224\250\346\214\207\345\257\274.md" @@ -79,40 +79,42 @@ >![](public_sys-resources/icon-note.gif) **说明:** >模型管理操作需要在数据库正常的状态下进行。 -1. 新增模型: +1. 新增模型: - INSERT INTO gs\_opt\_model values\('......'\); + ``` + INSERT INTO gs\_opt\_model values\('......'\); + ``` - 示例: + 示例: - ``` - INSERT INTO gs_opt_model values('rlstm', 'model_name', 'datname', '127.0.0.1', 5000, 2000, 1, -1, 64, 512, 0 , false, false, '{S, T}', '{0,0}', '{0,0}', 'Text'); - ``` + ``` + INSERT INTO gs_opt_model values('rlstm', 'model_name', 'datname', '127.0.0.1', 5000, 2000, 1, -1, 64, 512, 0 , false, false, '{S, T}', '{0,0}', '{0,0}', 'Text'); + ``` - >![](public_sys-resources/icon-note.gif) **说明:** - >- 具体模型参数设置请参考[GS\_OPT\_MODEL](GS_OPT_MODEL.md)。 - >- 目前 "template\_name" 列只支持 "rlstm"; - >- "datname" 列请和用于模型使用和训练的数据库保持一致,否则无法使用。 - >- "model\_name" 一列需要满足unique约束。 - >- 其他参数设置见产品文档[最佳实践](最佳实践.md)部分。 + >![](public_sys-resources/icon-note.gif) **说明:** + >- 具体模型参数设置请参考[GS\_OPT\_MODEL](GS_OPT_MODEL.md)。 + >- 目前 "template\_name" 列只支持 "rlstm"; + >- "datname" 列请和用于模型使用和训练的数据库保持一致,否则无法使用。 + >- "model\_name" 一列需要满足unique约束。 + >- 其他参数设置见产品文档[最佳实践](最佳实践.md)部分。 -2. 修改模型参数: +2. 修改模型参数: - ``` - UPDATE gs_opt_model SET = WHERE model_name = ; - ``` + ``` + UPDATE gs_opt_model SET = WHERE model_name = ; + ``` -3. 删除模型: +3. 删除模型: - ``` - DELETE FROM gs_opt_model WHERE model_name = ; - ``` + ``` + DELETE FROM gs_opt_model WHERE model_name = ; + ``` -4. 查询现有模型及其状态: +4. 查询现有模型及其状态: - ``` - SELECT * FROM gs_opt_model; - ``` + ``` + SELECT * FROM gs_opt_model; + ``` ## 模型训练(系统管理员用户) diff --git "a/content/zh/docs/Developerguide/\345\210\206\346\236\220\350\241\250.md" "b/content/zh/docs/Developerguide/\345\210\206\346\236\220\350\241\250.md" index 0279c27c257a38fece38d5fe59106a8ab73dcabf..0be1076aa6d689ff479ae6278d94949b5a6b3a04 100644 --- "a/content/zh/docs/Developerguide/\345\210\206\346\236\220\350\241\250.md" +++ "b/content/zh/docs/Developerguide/\345\210\206\346\236\220\350\241\250.md" @@ -11,7 +11,7 @@ ANALYZE支持的表类型有行/列存表。ANALYZE同时也支持对本地表 以表product\_info为例,ANALYZE命令如下: ``` - postgres=# ANALYZE product_info; + ANALYZE product_info; ``` ``` diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206schema.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206schema.md" index a900169c3cbd64a02c5c0c2595c5905fe8bddc0d..a7409fdf73908f9b404fe68e860f120a8a596caf 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206schema.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206schema.md" @@ -20,7 +20,7 @@ schema又称作模式。通过管理schema,允许多个用户使用同一数 - 执行如下命令来创建一个schema。 ``` - postgres=# CREATE SCHEMA myschema; + CREATE SCHEMA myschema; ``` 当结果显示为如下信息,则表示成功创建一个名为myschema的schema。 @@ -34,7 +34,7 @@ schema又称作模式。通过管理schema,允许多个用户使用同一数 - 执行如下命令在创建schema时指定owner。 ``` - postgres=# CREATE SCHEMA myschema AUTHORIZATION omm; + CREATE SCHEMA myschema AUTHORIZATION omm; ``` 当结果显示为如下信息,则表示成功创建一个属于omm用户,名为myschema的schema。 diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\210\206\345\214\272\350\241\250.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\210\206\345\214\272\350\241\250.md" index 5ce7fc5a8e93875904940ae3c19595135f6f0b8f..79f4d33fa5c4ef747e70c28a0be6f0aa24d38ad1 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\210\206\345\214\272\350\241\250.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\210\206\345\214\272\350\241\250.md" @@ -37,7 +37,7 @@ openGauss数据库支持的分区表为范围分区表。 - 创建分区表 ``` - postgres=# CREATE TABLE tpcds.customer_address + CREATE TABLE tpcds.customer_address ( ca_address_sk integer NOT NULL , ca_address_id character(16) NOT NULL , diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\272\217\345\210\227.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\272\217\345\210\227.md" index 6ecec0527a5b29fcef4217f2099c686d8c943425..2bb2f2a2be0c079ce6a0a5fba0d1e1639044698f 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\272\217\345\210\227.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\345\272\217\345\210\227.md" @@ -14,7 +14,7 @@ 方法一: 声明字段类型为序列整型来定义标识符字段。例如: ``` -postgres=# CREATE TABLE T1 +CREATE TABLE T1 ( id serial, name text @@ -32,7 +32,7 @@ CREATE TABLE 1. 创建序列 ``` - postgres=# CREATE SEQUENCE seq1 cache 100; + CREATE SEQUENCE seq1 cache 100; ``` 当结果显示为如下信息,则表示创建成功。 @@ -44,7 +44,7 @@ CREATE TABLE 2. 指定为某一字段的默认值,使该字段具有唯一标识属性。 ``` - postgres=# CREATE TABLE T2 + CREATE TABLE T2 ( id int not null default nextval('seq1'), name text @@ -62,7 +62,7 @@ CREATE TABLE 将序列和一个表的指定字段进行关联。这样,在删除那个字段或其所在表的时候会自动删除已关联的序列。 ``` - postgres=# ALTER SEQUENCE seq1 OWNED BY T2.id; + ALTER SEQUENCE seq1 OWNED BY T2.id; ``` 当结果显示为如下信息,则表示指定成功。 diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\346\225\260\346\215\256\345\272\223.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\346\225\260\346\215\256\345\272\223.md" index fb872a4e930b2d5d8fadc4070c094fb42e60ba60..2bb15c78ae5221a53484bec68501acc61ffcb5c1 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\346\225\260\346\215\256\345\272\223.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\346\225\260\346\215\256\345\272\223.md" @@ -51,13 +51,13 @@ - 使用\\l元命令查看数据库系统的数据库列表。 ``` - postgres=# \l + \l ``` - 使用如下命令通过系统表pg\_database查询数据库列表。 ``` - postgres=# SELECT datname FROM pg_database; + SELECT datname FROM pg_database; ``` 3. 修改数据库 diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\347\264\242\345\274\225.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\347\264\242\345\274\225.md" index 847dda455f64ed3a9c560c60f6720fc0a64fd940..07ca3391f6ff5705db1e3ab7cea7d11660904212 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\347\264\242\345\274\225.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\347\264\242\345\274\225.md" @@ -26,7 +26,7 @@ - 创建分区表索引tpcds\_web\_returns\_p2\_index1,不指定索引分区的名称。 ``` - postgres=# CREATE INDEX tpcds_web_returns_p2_index1 ON tpcds.web_returns_p2 (ca_address_id) LOCAL; + CREATE INDEX tpcds_web_returns_p2_index1 ON tpcds.web_returns_p2 (ca_address_id) LOCAL; ``` 当结果显示为如下信息,则表示创建成功。 @@ -38,7 +38,7 @@ - 创建分区索引tpcds\_web\_returns\_p2\_index2,并指定索引分区的名称。 ``` - postgres=# CREATE INDEX tpcds_web_returns_p2_index2 ON tpcds.web_returns_p2 (ca_address_sk) LOCAL + CREATE INDEX tpcds_web_returns_p2_index2 ON tpcds.web_returns_p2 (ca_address_sk) LOCAL ( PARTITION web_returns_p2_P1_index, PARTITION web_returns_p2_P2_index TABLESPACE example3, @@ -62,7 +62,7 @@ - 修改索引分区_web\_returns\_p2\_P2\_index_的表空间为example1。 ``` - postgres=# ALTER INDEX tpcds.tpcds_web_returns_p2_index2 MOVE PARTITION web_returns_p2_P2_index TABLESPACE example1; + ALTER INDEX tpcds.tpcds_web_returns_p2_index2 MOVE PARTITION web_returns_p2_P2_index TABLESPACE example1; ``` 当结果显示为如下信息,则表示修改成功。 @@ -74,7 +74,7 @@ - 修改索引分区_web\_returns\_p2\_P3\_index_的表空间为example2。 ``` - postgres=# ALTER INDEX tpcds.tpcds_web_returns_p2_index2 MOVE PARTITION web_returns_p2_P3_index TABLESPACE example2; + ALTER INDEX tpcds.tpcds_web_returns_p2_index2 MOVE PARTITION web_returns_p2_P3_index TABLESPACE example2; ``` 当结果显示为如下信息,则表示修改成功。 @@ -89,7 +89,7 @@ 执行如下命令对索引分区_web\_returns\_p2\_P8\_index_重命名_web\_returns\_p2\_P8\_index\__new。 ``` - postgres=# ALTER INDEX tpcds.tpcds_web_returns_p2_index2 RENAME PARTITION web_returns_p2_P8_index TO web_returns_p2_P8_index_new; + ALTER INDEX tpcds.tpcds_web_returns_p2_index2 RENAME PARTITION web_returns_p2_P8_index TO web_returns_p2_P8_index_new; ``` 当结果显示为如下信息,则表示重命名成功。 @@ -102,13 +102,13 @@ - 执行如下命令查询系统和用户定义的所有索引。 ``` - postgres=# SELECT RELNAME FROM PG_CLASS WHERE RELKIND='i'; + SELECT RELNAME FROM PG_CLASS WHERE RELKIND='i'; ``` - 执行如下命令查询指定索引的信息。 ``` - postgres=# \di+ tpcds.tpcds_web_returns_p2_index2 + \di+ tpcds.tpcds_web_returns_p2_index2 ``` @@ -177,7 +177,7 @@ openGauss支持4种创建索引的方式请参见[表1](#zh-cn_topic_0237120308_ 如果对于tpcds.customer\_address\_bak表,需要经常进行以下查询。 ``` - postgres=# SELECT ca_address_sk FROM tpcds.customer_address_bak WHERE ca_address_sk=14888; + SELECT ca_address_sk FROM tpcds.customer_address_bak WHERE ca_address_sk=14888; ``` 通常,数据库系统需要逐行扫描整个tpcds.customer\_address\_bak表以寻找所有匹配的元组。如果表tpcds.customer\_address\_bak的规模很大,但满足WHERE条件的只有少数几个(可能是零个或一个),则这种顺序扫描的性能就比较差。如果让数据库系统在ca\_address\_sk属性上维护一个索引,用于快速定位匹配的元组,则数据库系统只需要在搜索树上查找少数的几层就可以找到匹配的元组,这将会大大提高数据查询的性能。同样,在数据库中进行更新和删除操作时,索引也可以提升这些操作的性能。 @@ -194,7 +194,7 @@ openGauss支持4种创建索引的方式请参见[表1](#zh-cn_topic_0237120308_ 假如用户需要经常查询表tpcds.customer\_address\_bak中ca\_address\_sk是5050,且ca\_street\_number小于1000的记录,使用以下命令进行查询。 ``` - postgres=# SELECT ca_address_sk,ca_address_id FROM tpcds.customer_address_bak WHERE ca_address_sk = 5050 AND ca_street_number < 1000; + SELECT ca_address_sk,ca_address_id FROM tpcds.customer_address_bak WHERE ca_address_sk = 5050 AND ca_street_number < 1000; ``` 使用以下命令在字段ca\_address\_sk和ca\_street\_number上定义一个多字段索引。 @@ -218,7 +218,7 @@ openGauss支持4种创建索引的方式请参见[表1](#zh-cn_topic_0237120308_ 假如经常需要查询ca\_street\_number小于1000的信息,执行如下命令进行查询。 ``` - postgres=# SELECT * FROM tpcds.customer_address_bak WHERE trunc(ca_street_number) < 1000; + SELECT * FROM tpcds.customer_address_bak WHERE trunc(ca_street_number) < 1000; ``` 可以为上面的查询创建表达式索引: diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\241\250\347\251\272\351\227\264.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\241\250\347\251\272\351\227\264.md" index b914b4b39f32942d25ad392329b12f59a74644c8..679df49b8ad9d9f94a708fc8f4bdafbecead5535 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\241\250\347\251\272\351\227\264.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\241\250\347\251\272\351\227\264.md" @@ -27,7 +27,7 @@ 1. 执行如下命令创建用户jack。 ``` - postgres=# CREATE USER jack IDENTIFIED BY 'Bigdata@123'; + CREATE USER jack IDENTIFIED BY 'Bigdata@123'; ``` 当结果显示为如下信息,则表示创建成功。 @@ -39,7 +39,7 @@ 2. 执行如下命令创建表空间。 ``` - postgres=# CREATE TABLESPACE fastspace RELATIVE LOCATION 'tablespace/tablespace_1'; + CREATE TABLESPACE fastspace RELATIVE LOCATION 'tablespace/tablespace_1'; ``` 当结果显示为如下信息,则表示创建成功。 @@ -53,7 +53,7 @@ 3. 数据库系统管理员执行如下命令将“fastspace”表空间的访问权限赋予数据用户jack。 ``` - postgres=# GRANT CREATE ON TABLESPACE fastspace TO jack; + GRANT CREATE ON TABLESPACE fastspace TO jack; ``` 当结果显示为如下信息,则表示赋予成功。 @@ -73,7 +73,7 @@ - 方式1:执行如下命令在指定表空间创建表。 ``` - postgres=# CREATE TABLE foo(i int) TABLESPACE fastspace; + CREATE TABLE foo(i int) TABLESPACE fastspace; ``` 当结果显示为如下信息,则表示创建成功。 @@ -98,13 +98,13 @@ - 方式1:检查pg\_tablespace系统表。如下命令可查到系统和用户定义的全部表空间。 ``` - postgres=# SELECT spcname FROM pg_tablespace; + SELECT spcname FROM pg_tablespace; ``` - 方式2:使用gsql程序的元命令查询表空间。 ``` - postgres=# \db + \db ``` @@ -112,7 +112,7 @@ 1. 查询表空间的当前使用情况。 ``` - postgres=# SELECT PG_TABLESPACE_SIZE('example'); + SELECT PG_TABLESPACE_SIZE('example'); ``` 返回如下信息: diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\247\206\345\233\276.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\247\206\345\233\276.md" index ad1084e5a1a4f302ea93ad96c378a75c015f559c..75ef663e66a587f667465d7669918dd14b60805a 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\247\206\345\233\276.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\345\222\214\347\256\241\347\220\206\350\247\206\345\233\276.md" @@ -25,7 +25,7 @@ 执行如下命令查询MyView视图。 ``` - postgres=# SELECT * FROM MyView; + SELECT * FROM MyView; ``` - 查看某视图的具体信息 diff --git "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\350\241\250.md" "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\350\241\250.md" index da5364bf7057db9d6b94f68d87e6cc6fd9d6da94..7f4c9d60e3fc6816a0feef9e2923aafa63fe7691 100644 --- "a/content/zh/docs/Developerguide/\345\210\233\345\273\272\350\241\250.md" +++ "b/content/zh/docs/Developerguide/\345\210\233\345\273\272\350\241\250.md" @@ -9,7 +9,7 @@ 执行如下命令创建表。 ``` -postgres=# CREATE TABLE customer_t1 +CREATE TABLE customer_t1 ( c_customer_sk integer, c_customer_id char(5), diff --git "a/content/zh/docs/Developerguide/\345\210\240\351\231\244\350\241\250\344\270\255\346\225\260\346\215\256.md" "b/content/zh/docs/Developerguide/\345\210\240\351\231\244\350\241\250\344\270\255\346\225\260\346\215\256.md" index 61f36cd4973a1c6aad45085da48dd208b97adbfe..0969e9a290385eecb8cd0bebb303b978b8bbc888 100644 --- "a/content/zh/docs/Developerguide/\345\210\240\351\231\244\350\241\250\344\270\255\346\225\260\346\215\256.md" +++ "b/content/zh/docs/Developerguide/\345\210\240\351\231\244\350\241\250\344\270\255\346\225\260\346\215\256.md" @@ -7,18 +7,18 @@ SQL不能直接访问独立的行,只能通过声明被删除行匹配的条 使用DELETE命令删除行,如果删除表customer\_t1中所有c\_customer\_sk为3869的记录: ``` -postgres=# DELETE FROM customer_t1 WHERE c_customer_sk = 3869; +DELETE FROM customer_t1 WHERE c_customer_sk = 3869; ``` 如果执行如下命令之一,会删除表中所有的行。 ``` -postgres=# DELETE FROM customer_t1; +DELETE FROM customer_t1; ``` ``` 或: -postgres=# TRUNCATE TABLE customer_t1; +TRUNCATE TABLE customer_t1; ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -27,6 +27,6 @@ postgres=# TRUNCATE TABLE customer_t1; 删除创建的表: ``` -postgres=# DROP TABLE customer_t1; +DROP TABLE customer_t1; ``` diff --git "a/content/zh/docs/Developerguide/\345\220\221\350\241\250\344\270\255\346\217\222\345\205\245\346\225\260\346\215\256.md" "b/content/zh/docs/Developerguide/\345\220\221\350\241\250\344\270\255\346\217\222\345\205\245\346\225\260\346\215\256.md" index 6aec620adfbac8f83a6993fc54501b230cc6d0f7..83f26884c36a18c666b399bced0a28fc987b0a79 100644 --- "a/content/zh/docs/Developerguide/\345\220\221\350\241\250\344\270\255\346\217\222\345\205\245\346\225\260\346\215\256.md" +++ "b/content/zh/docs/Developerguide/\345\220\221\350\241\250\344\270\255\346\217\222\345\205\245\346\225\260\346\215\256.md" @@ -154,13 +154,13 @@ postgres=# CREATE TABLE table2(id int, a char(20), b varchar(20),c varchar(20)); 数据值是按照这些字段在表中出现的顺序列出的,并且用逗号分隔。通常数据值是文本(常量),但也允许使用标量表达式。 ``` - postgres=# INSERT INTO customer_t1(c_customer_sk, c_customer_id, c_first_name) VALUES (3769, 'hello', 'Grace'); + INSERT INTO customer_t1(c_customer_sk, c_customer_id, c_first_name) VALUES (3769, 'hello', 'Grace'); ``` 如果用户已经知道表中字段的顺序,也可无需列出表中的字段。例如以下命令与上面的命令效果相同。 ``` - postgres=# INSERT INTO customer_t1 VALUES (3769, 'hello', 'Grace'); + INSERT INTO customer_t1 VALUES (3769, 'hello', 'Grace'); ``` 如果用户不知道所有字段的数值,可以忽略其中的一些。没有数值的字段将被填充为字段的缺省值。例如: @@ -182,7 +182,7 @@ postgres=# CREATE TABLE table2(id int, a char(20), b varchar(20),c varchar(20)); - 如果需要在表中插入多行,请使用以下命令: ``` - postgres=# INSERT INTO customer_t1 (c_customer_sk, c_customer_id, c_first_name) VALUES + INSERT INTO customer_t1 (c_customer_sk, c_customer_id, c_first_name) VALUES (6885, 'maps', 'Joes'), (4321, 'tpcds', 'Lily'), (9527, 'world', 'James'); @@ -210,7 +210,7 @@ postgres=# CREATE TABLE table2(id int, a char(20), b varchar(20),c varchar(20)); - 删除备份表 ``` - postgres=# DROP TABLE customer_t2 CASCADE; + DROP TABLE customer_t2 CASCADE; ``` >![](public_sys-resources/icon-note.gif) **说明:** diff --git "a/content/zh/docs/Developerguide/\345\256\241\350\256\241\346\246\202\350\277\260.md" "b/content/zh/docs/Developerguide/\345\256\241\350\256\241\346\246\202\350\277\260.md" index 36ed724b75b1b3ed8573e36e4ed51c26f401648a..8301946986474edb64fdd6698a1c6eeed16a9845 100644 --- "a/content/zh/docs/Developerguide/\345\256\241\350\256\241\346\246\202\350\277\260.md" +++ "b/content/zh/docs/Developerguide/\345\256\241\350\256\241\346\246\202\350\277\260.md" @@ -443,7 +443,7 @@ 1. 用show命令显示审计总开关audit\_enabled的值。 ``` - postgres=# SHOW audit_enabled; + SHOW audit_enabled; ``` 如果显示为off,执行“\\q”命令退出数据库。 diff --git "a/content/zh/docs/Developerguide/\345\257\271\350\241\250\346\211\247\350\241\214VACUUM.md" "b/content/zh/docs/Developerguide/\345\257\271\350\241\250\346\211\247\350\241\214VACUUM.md" index 761d7f6e6d94d39cc22b6970970272db196c2772..4f548793f3d48000ef1e6da63b753cc977cb0d9c 100644 --- "a/content/zh/docs/Developerguide/\345\257\271\350\241\250\346\211\247\350\241\214VACUUM.md" +++ "b/content/zh/docs/Developerguide/\345\257\271\350\241\250\346\211\247\350\241\214VACUUM.md" @@ -7,7 +7,7 @@ 以表product\_info为例,VACUUM FULL命令如下: ``` - postgres=# VACUUM FULL product_info + VACUUM FULL product_info ``` ``` diff --git "a/content/zh/docs/Developerguide/\346\233\264\346\226\260\347\273\237\350\256\241\344\277\241\346\201\257.md" "b/content/zh/docs/Developerguide/\346\233\264\346\226\260\347\273\237\350\256\241\344\277\241\346\201\257.md" index ce0e541300726e9aefdb8fcefda21519a0f5a503..820d20385665dab611644383e6d4c5d6b4b7d905 100644 --- "a/content/zh/docs/Developerguide/\346\233\264\346\226\260\347\273\237\350\256\241\344\277\241\346\201\257.md" +++ "b/content/zh/docs/Developerguide/\346\233\264\346\226\260\347\273\237\350\256\241\344\277\241\346\201\257.md" @@ -17,19 +17,26 @@ ANALYZE语句可收集与数据库中表内容相关的统计信息,统计结 使用以下命令更新某个表或者整个database的统计信息。 ``` -ANALYZE tablename; --更新单个表的统计信息 -ANALYZE; --更新全库的统计信息 +--更新单个表的统计信息。 +ANALYZE tablename; +--更新全库的统计信息。 +ANALYZE; ``` 使用以下命令进行多列统计信息相关操作。 ``` -ANALYZE tablename ((column_1, column_2)); --收集tablename表的column_1、column_2列的多列统计信息 + --收集tablename表的column_1、column_2列的多列统计信息。 +ANALYZE tablename ((column_1, column_2)); -ALTER TABLE tablename ADD STATISTICS ((column_1, column_2)); --添加tablename表的column_1、column_2列的多列统计信息声明 -ANALYZE tablename; --收集单列统计信息,并收集已声明的多列统计信息 +--添加tablename表的column_1、column_2列的多列统计信息声明。 +ALTER TABLE tablename ADD STATISTICS ((column_1, column_2)); -ALTER TABLE tablename DELETE STATISTICS ((column_1, column_2)); --删除tablename表的column_1、column_2列的多列统计信息或其声明 +--收集单列统计信息,并收集已声明的多列统计信息。 +ANALYZE tablename; + + --删除tablename表的column_1、column_2列的多列统计信息或其声明。 +ALTER TABLE tablename DELETE STATISTICS ((column_1, column_2)); ``` >![](public_sys-resources/icon-notice.gif) **须知:** diff --git "a/content/zh/docs/Developerguide/\346\233\264\346\226\260\350\241\250\344\270\255\346\225\260\346\215\256.md" "b/content/zh/docs/Developerguide/\346\233\264\346\226\260\350\241\250\344\270\255\346\225\260\346\215\256.md" index 75fc7f756abb6e52fd230f333fc061709baae2aa..27356fcb26268e8dfae42cc6f1867fb4b3383684 100644 --- "a/content/zh/docs/Developerguide/\346\233\264\346\226\260\350\241\250\344\270\255\346\225\260\346\215\256.md" +++ "b/content/zh/docs/Developerguide/\346\233\264\346\226\260\350\241\250\344\270\255\346\225\260\346\215\256.md" @@ -15,7 +15,7 @@ SQL通常不会为数据行提供唯一标识,因此无法直接声明需要 需要将表customer\_t1中c\_customer\_sk为9527的地域重新定义为9876: ``` -postgres=# UPDATE customer_t1 SET c_customer_sk = 9876 WHERE c_customer_sk = 9527; +UPDATE customer_t1 SET c_customer_sk = 9876 WHERE c_customer_sk = 9527; ``` 这里的表名称也可以使用模式名修饰,否则会从默认的模式路径找到这个表。SET后面紧跟字段和新的字段值。新的字段值不仅可以是常量,也可以是变量表达式。 @@ -23,7 +23,7 @@ postgres=# UPDATE customer_t1 SET c_customer_sk = 9876 WHERE c_customer_sk = 952 比如,把所有c\_customer\_sk的值增加100: ``` -postgres=# UPDATE customer_t1 SET c_customer_sk = c_customer_sk + 100; +UPDATE customer_t1 SET c_customer_sk = c_customer_sk + 100; ``` 在这里省略了WHERE子句,表示表中的所有行都要被更新。如果出现了WHERE子句,那么只有匹配其条件的行才会被更新。 @@ -33,7 +33,7 @@ postgres=# UPDATE customer_t1 SET c_customer_sk = c_customer_sk + 100; 用户可以在一个UPDATE命令中更新更多的字段,方法是在SET子句中列出更多赋值,比如: ``` -postgres=# UPDATE customer_t1 SET c_customer_id = 'Admin', c_first_name = 'Local' WHERE c_customer_sk = 4421; +UPDATE customer_t1 SET c_customer_id = 'Admin', c_first_name = 'Local' WHERE c_customer_sk = 4421; ``` 批量更新或删除数据后,会在数据文件中产生大量的删除标记,查询过程中标记删除的数据也是需要扫描的。故多次批量更新/删除后,标记删除的数据量过大会严重影响查询的性能。建议在批量更新/删除业务会反复执行的场景下,定期执行VACUUM FULL以保持查询性能。 diff --git "a/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\217\202\346\225\260\345\275\223\345\211\215\345\217\226\345\200\274.md" "b/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\217\202\346\225\260\345\275\223\345\211\215\345\217\226\345\200\274.md" index 86c331b15faf0e4d4f47c27ec294fe242e3671be..93c54fe5d3544fc6e391efde7161b2090758c305 100644 --- "a/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\217\202\346\225\260\345\275\223\345\211\215\345\217\226\345\200\274.md" +++ "b/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\217\202\346\225\260\345\275\223\345\211\215\345\217\226\345\200\274.md" @@ -28,7 +28,7 @@ openGauss安装后,有一套默认的运行参数,为了使openGauss与业 - 使用如下命令查看单个参数: ``` - postgres=# SHOW server_version; + SHOW server_version; ``` server\_version显示数据库版本信息的参数。 @@ -36,21 +36,21 @@ openGauss安装后,有一套默认的运行参数,为了使openGauss与业 - 使用如下命令查看所有参数: ``` - postgres=# SHOW ALL; + SHOW ALL; ``` - 方法二:使用pg\_settings视图。 - 使用如下命令查看单个参数: - + ``` - postgres=# SELECT * FROM pg_settings WHERE NAME='server_version'; + SELECT * FROM pg_settings WHERE NAME='server_version'; ``` - + - 使用如下命令查看所有参数: - + ``` - postgres=# SELECT * FROM pg_settings; + SELECT * FROM pg_settings; ``` diff --git "a/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\256\241\350\256\241\347\273\223\346\236\234.md" "b/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\256\241\350\256\241\347\273\223\346\236\234.md" index 8b13bbdcf7227f1d1297e463533fbe36f4424880..b3a5b4dc781997c266f70626604fbddd1d5fef1c 100644 --- "a/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\256\241\350\256\241\347\273\223\346\236\234.md" +++ "b/content/zh/docs/Developerguide/\346\237\245\347\234\213\345\256\241\350\256\241\347\273\223\346\236\234.md" @@ -46,7 +46,7 @@ 3. 查询审计记录。 ``` - postgres=# SELECT * FROM pg_query_audit('2015-07-15 08:00:00','2015-07-15 09:47:33'); + SELECT * FROM pg_query_audit('2015-07-15 08:00:00','2015-07-15 09:47:33'); ``` 查询结果如下: diff --git "a/content/zh/docs/Developerguide/\346\237\245\347\234\213\346\225\260\346\215\256.md" "b/content/zh/docs/Developerguide/\346\237\245\347\234\213\346\225\260\346\215\256.md" index a3183d3a36b52e2274e236ddf95bf94d22b37b84..daf57f45c3b41434b01aee03ae4b0468a23bc4fa 100644 --- "a/content/zh/docs/Developerguide/\346\237\245\347\234\213\346\225\260\346\215\256.md" +++ "b/content/zh/docs/Developerguide/\346\237\245\347\234\213\346\225\260\346\215\256.md" @@ -3,49 +3,49 @@ - 使用系统表pg\_tables查询数据库所有表的信息。 ``` - postgres=# SELECT * FROM pg_tables; + SELECT * FROM pg_tables; ``` - 使用gsql的\\d+命令查询表的属性。 ``` - postgres=# \d+ customer_t1; + \d+ customer_t1; ``` - 执行如下命令查询表customer\_t1****的数据量。 ``` - postgres=# SELECT count(*) FROM customer_t1; + SELECT count(*) FROM customer_t1; ``` - 执行如下命令查询表customer\_t1的所有数据。 ``` - postgres=# SELECT * FROM customer_t1; + SELECT * FROM customer_t1; ``` - 执行如下命令只查询字段c\_customer\_sk的数据。 ``` - postgres=# SELECT c_customer_sk FROM customer_t1; + SELECT c_customer_sk FROM customer_t1; ``` - 执行如下命令过滤字段c\_customer\_sk的重复数据。 ``` - postgres=# SELECT DISTINCT( c_customer_sk ) FROM customer_t1; + SELECT DISTINCT( c_customer_sk ) FROM customer_t1; ``` - 执行如下命令查询字段c\_customer\_sk为3869的所有数据。 ``` - postgres=# SELECT * FROM customer_t1 WHERE c_customer_sk = 3869; + SELECT * FROM customer_t1 WHERE c_customer_sk = 3869; ``` - 执行如下命令按照字段c\_customer\_sk进行排序。 ``` - postgres=# SELECT * FROM customer_t1 ORDER BY c_customer_sk; + SELECT * FROM customer_t1 ORDER BY c_customer_sk; ``` diff --git "a/content/zh/docs/Developerguide/\347\224\250\346\210\267.md" "b/content/zh/docs/Developerguide/\347\224\250\346\210\267.md" index d14714e2b549f5215d249c2c222321dfedae1c86..1aa76fe663464224a5057c9366c951d5f0510333 100644 --- "a/content/zh/docs/Developerguide/\347\224\250\346\210\267.md" +++ "b/content/zh/docs/Developerguide/\347\224\250\346\210\267.md" @@ -23,13 +23,13 @@ - 要查看用户列表,请查询视图[PG\_USER](PG_USER.md): ``` - postgres=# SELECT * FROM pg_user; + SELECT * FROM pg_user; ``` - 要查看用户属性,请查询系统表[PG\_AUTHID](PG_AUTHID.md): ``` - postgres=# SELECT * FROM pg_authid; + SELECT * FROM pg_authid; ``` @@ -40,7 +40,7 @@ [三权分立](三权分立.md)情况下,管理员对其他用户放在属于各自模式下的表无权限。但是,这种无权限包含了无控制权限,因此不能满足上面的诉求。为此,openGauss提供了私有用户方案。即在非三权分立模式下,创建具有INDEPENDENT属性的私有用户。 ``` -postgres=# CREATE USER user_independent WITH INDEPENDENT IDENTIFIED BY "1234@abc"; +CREATE USER user_independent WITH INDEPENDENT IDENTIFIED BY "1234@abc"; ``` 针对该用户的对象,系统管理员和拥有CREATEROLE属性的安全管理员在未经其授权前,只能进行控制操作(DROP、ALTER、TRUNCATE),无权进行INSERT、DELETE、SELECT、UPDATE、COPY、GRANT、REVOKE、ALTER OWNER操作。 diff --git "a/content/zh/docs/Developerguide/\347\224\250\346\210\267\346\235\203\351\231\220\350\256\276\347\275\256.md" "b/content/zh/docs/Developerguide/\347\224\250\346\210\267\346\235\203\351\231\220\350\256\276\347\275\256.md" index 949fd53fbcdea8cf9f493402681fb75509f95847..886b6cd7b1919fbdb6b120b947538ec86aa9c927 100644 --- "a/content/zh/docs/Developerguide/\347\224\250\346\210\267\346\235\203\351\231\220\350\256\276\347\275\256.md" +++ "b/content/zh/docs/Developerguide/\347\224\250\346\210\267\346\235\203\351\231\220\350\256\276\347\275\256.md" @@ -17,7 +17,7 @@ 新建一个角色lily,同时给角色指定系统权限CREATEDB: ``` - postgres=# CREATE ROLE lily WITH CREATEDB PASSWORD "Bigdata@123"; + CREATE ROLE lily WITH CREATEDB PASSWORD "Bigdata@123"; ``` 2. 给角色赋予对象权限,请使用[GRANT](GRANT.md)。 @@ -32,7 +32,7 @@ 3. 将角色的权限赋予用户。 ``` - postgres=# GRANT lily to joe; + GRANT lily to joe; ``` >![](public_sys-resources/icon-note.gif) **说明:** diff --git "a/content/zh/docs/Developerguide/\347\256\241\347\220\206\345\221\230.md" "b/content/zh/docs/Developerguide/\347\256\241\347\220\206\345\221\230.md" index 8839b025fc87a28db9a4135907edf9537d110664..403583d50f584be8206c2af11b9630ee2dc7579d 100644 --- "a/content/zh/docs/Developerguide/\347\256\241\347\220\206\345\221\230.md" +++ "b/content/zh/docs/Developerguide/\347\256\241\347\220\206\345\221\230.md" @@ -13,13 +13,13 @@ openGauss安装过程中自动生成的帐户称为初始用户。初始用户 要创建新的系统管理员,请以初始用户或者系统管理员用户身份连接数据库,并使用带SYSADMIN选项的[CREATE USER](CREATE-USER.md)语句或 [ALTER USER](ALTER-USER.md)语句进行设置。 ``` -postgres=# CREATE USER sysadmin WITH SYSADMIN password "Bigdata@123"; +CREATE USER sysadmin WITH SYSADMIN password "Bigdata@123"; ``` 或者 ``` -postgres=# ALTER USER joe SYSADMIN; +ALTER USER joe SYSADMIN; ``` ALTER USER时,要求用户已存在。 @@ -31,13 +31,13 @@ ALTER USER时,要求用户已存在。 要创建新的监控管理员,请以初始用户身份连接数据库,并使用带MONADMIN选项的[CREATE USER](CREATE-USER.md)语句或 [ALTER USER](ALTER-USER.md)语句进行设置。 ``` -postgres=# CREATE USER monadmin WITH MONADMIN password "Bigdata@123"; +CREATE USER monadmin WITH MONADMIN password "Bigdata@123"; ``` 或者 ``` -postgres=# ALTER USER joe MONADMIN; +ALTER USER joe MONADMIN; ``` ALTER USER时,要求用户已存在。 diff --git "a/content/zh/docs/Developerguide/\347\273\264\346\212\244\345\256\241\350\256\241\346\227\245\345\277\227.md" "b/content/zh/docs/Developerguide/\347\273\264\346\212\244\345\256\241\350\256\241\346\227\245\345\277\227.md" index 0aca73388296b4a155c6626304415519f1a7e4d9..3feb2a95758d338e3c5964a3ac48146b28831332 100644 --- "a/content/zh/docs/Developerguide/\347\273\264\346\212\244\345\256\241\350\256\241\346\227\245\345\277\227.md" +++ "b/content/zh/docs/Developerguide/\347\273\264\346\212\244\345\256\241\350\256\241\346\227\245\345\277\227.md" @@ -177,7 +177,7 @@ 1. 使用show命令获得审计文件所在目录(audit\_directory)。 ``` - postgres=# SHOW audit_directory; + SHOW audit_directory; ``` 2. 将审计目录整个拷贝出来进行保存。 @@ -189,7 +189,7 @@ 以删除2012/9/20到2012/9/21之间的审计记录为例: ``` - postgres=# SELECT pg_delete_audit('2012-09-20 ','2012-09-21'); + SELECT pg_delete_audit('2012-09-20 ','2012-09-21'); ``` diff --git "a/content/zh/docs/Developerguide/\350\256\276\347\275\256\345\270\220\345\217\267\346\234\211\346\225\210\346\234\237.md" "b/content/zh/docs/Developerguide/\350\256\276\347\275\256\345\270\220\345\217\267\346\234\211\346\225\210\346\234\237.md" index 80e8451e8bc2801a0186372631ed3223b2cea193..4fd1caba85cdcd3a21f8ea8d7047d05344eeac15 100644 --- "a/content/zh/docs/Developerguide/\350\256\276\347\275\256\345\270\220\345\217\267\346\234\211\346\225\210\346\234\237.md" +++ "b/content/zh/docs/Developerguide/\350\256\276\347\275\256\345\270\220\345\217\267\346\234\211\346\225\210\346\234\237.md" @@ -30,7 +30,7 @@ 3. 创建用户并制定用户的有效开始时间和有效结束时间。 ``` - postgres=# CREATE USER joe WITH PASSWORD 'Bigdata@123' VALID BEGIN '2015-10-10 08:00:00' VALID UNTIL '2016-10-10 08:00:00'; + CREATE USER joe WITH PASSWORD 'Bigdata@123' VALID BEGIN '2015-10-10 08:00:00' VALID UNTIL '2016-10-10 08:00:00'; ``` 显示如下信息表示创建用户成功。 @@ -42,7 +42,7 @@ 4. 用户已不在有效使用期内,需要重新设定帐号的有效期,这包括有效开始时间和有效结束时间。 ``` - postgres=# ALTER USER joe WITH VALID BEGIN '2016-11-10 08:00:00' VALID UNTIL '2017-11-10 08:00:00'; + ALTER USER joe WITH VALID BEGIN '2016-11-10 08:00:00' VALID UNTIL '2017-11-10 08:00:00'; ``` 显示如下信息表示重新设定成功。 diff --git "a/content/zh/docs/Developerguide/\350\264\247\345\270\201\347\261\273\345\236\213.md" "b/content/zh/docs/Developerguide/\350\264\247\345\270\201\347\261\273\345\236\213.md" index c99f2b1d52301df1c06023a715edb5df59d94465..1a857aed0a4a83d110ad2d479820f9b13cd39cb6 100644 --- "a/content/zh/docs/Developerguide/\350\264\247\345\270\201\347\261\273\345\236\213.md" +++ "b/content/zh/docs/Developerguide/\350\264\247\345\270\201\347\261\273\345\236\213.md" @@ -32,7 +32,7 @@ numeric,int和bigint类型的值可以转化为money类型。如果从real和double precision类型转换到money类型,可以先转化为numeric类型,再转化为money类型,例如: ``` -postgres=# SELECT '12.34'::float8::numeric::money; +SELECT '12.34'::float8::numeric::money; ``` 这种用法是不推荐使用的。浮点数不应该用来处理货币类型,因为小数点的位数可能会导致错误。 @@ -40,7 +40,7 @@ postgres=# SELECT '12.34'::float8::numeric::money; money类型的值可以转换为numeric类型而不丢失精度。转换为其他类型可能丢失精度,并且必须通过以下两步来完成: ``` -postgres=# SELECT '52093.89'::money::numeric::float8; +SELECT '52093.89'::money::numeric::float8; ``` 当一个money类型的值除以另一个money类型的值时,结果是double precision(也就是,一个纯数字,而不是money类型);在运算过程中货币单位相互抵消。 diff --git "a/content/zh/docs/Developerguide/\351\200\232\350\277\207\345\210\233\345\273\272\344\270\264\346\227\266\350\241\250\345\271\266\346\210\252\346\226\255\345\216\237\345\247\213\350\241\250\346\235\245\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" "b/content/zh/docs/Developerguide/\351\200\232\350\277\207\345\210\233\345\273\272\344\270\264\346\227\266\350\241\250\345\271\266\346\210\252\346\226\255\345\216\237\345\247\213\350\241\250\346\235\245\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" index b9bb681382197cc04b3509c3480dfea9acd94e02..99460d28768401baaf5c01d99bdfb4fd3e1da325 100644 --- "a/content/zh/docs/Developerguide/\351\200\232\350\277\207\345\210\233\345\273\272\344\270\264\346\227\266\350\241\250\345\271\266\346\210\252\346\226\255\345\216\237\345\247\213\350\241\250\346\235\245\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" +++ "b/content/zh/docs/Developerguide/\351\200\232\350\277\207\345\210\233\345\273\272\344\270\264\346\227\266\350\241\250\345\271\266\346\210\252\346\226\255\345\216\237\345\247\213\350\241\250\346\235\245\346\211\247\350\241\214\346\267\261\345\261\202\345\244\215\345\210\266.md" @@ -9,7 +9,7 @@ 1. 使用CREATE TABLE AS语句创建表customer\_t的临时表副本customer\_t\_temp。 ``` - postgres=# CREATE TABLE customer_t_temp AS SELECT * FROM customer_t; + CREATE TABLE customer_t_temp AS SELECT * FROM customer_t; ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -18,19 +18,19 @@ 2. 截断当前表customer\_t。 ``` - postgres=# TRUNCATE customer_t; + TRUNCATE customer_t; ``` 3. 使用INSERT INTO…SELECT语句从副本中向原始表中填充数据。 ``` - postgres=# INSERT INTO customer_t (SELECT * FROM customer_t_temp); + INSERT INTO customer_t (SELECT * FROM customer_t_temp); ``` 4. 删除临时表副本customer\_t\_temp。 ``` - postgres=# DROP TABLE customer_t_temp; + DROP TABLE customer_t_temp; ``` diff --git "a/content/zh/docs/Developerguide/\351\205\215\347\275\256\345\256\242\346\210\267\347\253\257\346\216\245\345\205\245\350\256\244\350\257\201.md" "b/content/zh/docs/Developerguide/\351\205\215\347\275\256\345\256\242\346\210\267\347\253\257\346\216\245\345\205\245\350\256\244\350\257\201.md" index 9aaf4d9e7a8a2e5ce54fe4627c729fe77a49e676..b9001fba594f080cd52ee7d1243dc5694afec40d 100644 --- "a/content/zh/docs/Developerguide/\351\205\215\347\275\256\345\256\242\346\210\267\347\253\257\346\216\245\345\205\245\350\256\244\350\257\201.md" +++ "b/content/zh/docs/Developerguide/\351\205\215\347\275\256\345\256\242\346\210\267\347\253\257\346\216\245\345\205\245\350\256\244\350\257\201.md" @@ -26,7 +26,7 @@ >![](public_sys-resources/icon-note.gif) **说明:** >- 使用“jack”用户前,需先本地连接数据库,并在数据库中使用如下语句建立“jack”用户: > ``` sql - > postgres=# CREATE USER jack PASSWORD 'Test@123'; + > CREATE USER jack PASSWORD 'Test@123'; > ``` > >- -N all表示openGauss的所有主机。 @@ -42,11 +42,11 @@ >- 10.10.0.30_/32_表示只允许IP地址为10.10.0.30的主机连接。此处的IP地址不能为openGauss内的IP,在使用过程中,请根据用户的网络进行配置修改。32表示子网掩码为1的位数,即255.255.255.255 > >- sha256表示连接时jack用户的密码使用sha256算法加密。 - + 这条命令在数据库主节点实例对应的“pg\_hba.conf”文件中添加了一条规则,用于对连接数据库主节点的客户端进行鉴定。 “pg\_hba.conf”文件中的每条记录可以是下面四种格式之一,四种格式的参数说明请参见[配置文件参考](配置文件参考.md)。 - + ``` local DATABASE USER METHOD [OPTIONS] host DATABASE USER ADDRESS METHOD [OPTIONS] @@ -55,10 +55,10 @@ hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] ``` 因为认证时系统是为每个连接请求顺序检查“pg\_hba.conf”里的记录的,所以这些记录的顺序是非常关键的。 - + >![](public_sys-resources/icon-note.gif) **说明:** >在配置“pg\_hba.conf”文件时,请依据通讯需求按照格式内容从上至下配置记录,优先级高的需求需要配置在前面。openGauss和扩容配置的IP优先级最高,用户手动配置的IP请放在这二者之后,如果已经进行的客户配置和扩容节点的IP在同一网段,请在扩容前删除,扩容成功后再进行配置。 - + 因此对于认证规则的配置建议如下: - 靠前的记录有比较严格的连接参数和比较弱的认证方法。 diff --git "a/content/zh/docs/Developerguide/\351\207\215\350\256\276\345\217\202\346\225\260.md" "b/content/zh/docs/Developerguide/\351\207\215\350\256\276\345\217\202\346\225\260.md" index 60aeb10e7d15b44edb41fe9f02f721ca9497d60b..39fa066c47f38eea9450da96808fa8d13ded11da 100644 --- "a/content/zh/docs/Developerguide/\351\207\215\350\256\276\345\217\202\346\225\260.md" +++ "b/content/zh/docs/Developerguide/\351\207\215\350\256\276\345\217\202\346\225\260.md" @@ -118,7 +118,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](#

在下次会话中生效。

  • 设置用户级别的参数
    postgres=# ALTER USER username SET paraname TO value;

    在下次会话中生效。

    -
  • 设置会话级别的参数
    postgres=# SET paraname TO value;
    +
  • 设置会话级别的参数
    SET paraname TO value;

    修改本次会话中的取值。退出会话后,设置将失效。

  • @@ -126,6 +126,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# + ## 操作步骤 使用方式一设置数据库参数,以在数据库主节点设置archive\_mode参数为例。 @@ -153,7 +154,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# >可以使用以下命令在数据库节点上设置archive\_mode参数为off。 >``` >gs_guc set -N all -I all -c "archive_mode=off" - >``` + >``` 4. 重启数据库使参数生效。 @@ -216,7 +217,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# >可以使用以下命令在数据库节点上设置authentication\_timeout参数为59s。 >``` >gs_guc reload -N all -I all -c "authentication_timeout = 59s" - >``` + >``` 4. 使用如下命令连接数据库。 @@ -285,7 +286,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# - 设置数据库级别的参数 ``` - postgres=# ALTER DATABASE postgres SET explain_perf_mode TO pretty; + ALTER DATABASE postgres SET explain_perf_mode TO pretty; ``` 当结果显示为如下信息,则表示设置成功。 @@ -299,7 +300,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# - 设置用户级别的参数 ``` - postgres=# ALTER USER omm SET explain_perf_mode TO pretty; + ALTER USER omm SET explain_perf_mode TO pretty; ``` 当结果显示为如下信息,则表示设置成功。 @@ -313,7 +314,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# - 设置会话级别的参数 ``` - postgres=# SET explain_perf_mode TO pretty; + SET explain_perf_mode TO pretty; ``` 当结果显示为如下信息,则表示设置成功。 @@ -368,7 +369,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# 4. 使用如下命令退出数据库。 ``` - postgres=# \q + \q ``` 5. 修改openGauss数据库主节点的最大连接数。 @@ -445,7 +446,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# 4. 使用如下命令退出数据库。 ``` - postgres=# \q + \q ``` 5. 修改openGauss数据库主节点的客户端认证最长时间。 @@ -516,7 +517,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# 4. 使用如下命令退出数据库。 ``` - postgres=# \q + \q ``` 5. 修改openGauss数据库节点的最大连接数。 @@ -594,7 +595,7 @@ openGauss提供了三种方式来修改GUC参数,具体操作请参考[表2](# 4. 使用如下命令退出数据库。 ``` - postgres=# \q + \q ``` 5. 修改openGauss数据库节点的客户端认证最长时间。