暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

openGauss每日一练第2天 - 学习心得体会

原创 尚雷 2022-11-25
1695

一、学习目标

这节课是本次实训第二节课程,本次课的重点是熟练掌握gsql工具的使用。熟悉Oracle的人可能都很熟悉sqlplus工具,gsql类似于Oracle的sqlplus,gsql是openGauss数据库提供的在命令行下连接数据库的工具,可通过gsql工具连接数据库服务器并进行相关数据库操作,其除了具有可操作数据库的基本功能,还提供了很多高级特性,方便用户使用。

1.1 gsql命令

如果想充分的了解gsql命令及其参数具体含义,可通过gsql --help来查看。

[omm@opengauss-node1 ~]$ gsql --help
gsql is the openGauss interactive terminal.

Usage:
  gsql [OPTION]... [DBNAME [USERNAME]]

General options:
  -c, --command=COMMAND             run only single command (SQL or internal) and exit
  -d, --dbname=DBNAME               database name to connect to (default: "omm")
  -f, --file=FILENAME               execute commands from file, then exit
  -l, --list                        list available databases, then exit
  -v, --set=, --variable=NAME=VALUE
                                    set gsql variable NAME to VALUE
  -V, --version                     output version information, then exit
  -X, --no-gsqlrc                   do not read startup file (~/.gsqlrc)
  -1 ("one"), --single-transaction
                                    execute command file as a single transaction
  -?, --help                        show this help, then exit

Input and output options:
  -a, --echo-all                    echo all input from script
  -e, --echo-queries                echo commands sent to server
  -E, --echo-hidden                 display queries that internal commands generate
  -k, --with-key=KEY                the key for decrypting the encrypted file
  -L, --log-file=FILENAME           send session log to file
  -m, --maintenance                 can connect to cluster during 2-pc transaction recovery
  -n, --no-libedit                  disable enhanced command line editing (libedit)
  -o, --output=FILENAME             send query results to file (or |pipe)
  -q, --quiet                       run quietly (no messages, only query output)
  -C, --enable-client-encryption            enable client encryption feature
  -s, --single-step                 single-step mode (confirm each query)
  -S, --single-line                 single-line mode (end of line terminates SQL command)

Output format options:
  -A, --no-align                    unaligned table output mode
  -F, --field-separator=STRING
                                    set field separator (default: "|")
  -H, --html                        HTML table output mode
  -P, --pset=VAR[=ARG]              set printing option VAR to ARG (see \pset command)
  -R, --record-separator=STRING
                                    set record separator (default: newline)
  -r                                if this parameter is set,use libedit 
  -t, --tuples-only                 print rows only
  -T, --table-attr=TEXT             set HTML table tag attributes (e.g., width, border)
  -x, --expanded                    turn on expanded table output
  -z, --field-separator-zero
                                    set field separator to zero byte
  -0, --record-separator-zero
                                    set record separator to zero byte
  -2, --pipeline                    use pipeline to pass the password, forbidden to use in terminal
                                    must use with -c or -f

Connection options:
  -h, --host=HOSTNAME               database server host or socket directory (default: "/opt/gaussdb/tmp")
                                    allow multi host IP address with comma separator in centralized cluster
  -p, --port=PORT                   database server port (default: "5432")
  -U, --username=USERNAME           database user name (default: "omm")
  -W, --password=PASSWORD           the password of specified database user

For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within gsql, or consult the gsql section in the openGauss documentation.

每个命令的具体含义还可以通过openGauss官网 https://docs.opengauss.org/zh/docs/3.1.0-lite/docs/Toolreference/gsql.html去查询gsql更详细的使用。

1.2 常用gsql命令及其含义

以下gsql常用命令及其含义,如下表:

元命令 具体含义
\l 列出所有可用的数据库,然后退出
\conninfo 显示会话的连接信息
\c \ DBNAME 是切换连接到该数据库
\du 显示数据库集簇中目前有哪些用户和角色
\dg dg用法同du
\db 显示当前数据库集簇中目前有哪些表空间
\dn 显示当前数据库有哪些数据库模式
\dt 显示当前数据库中所有的表
\d TableName 查看某个表信息
\d IndexName 查看某个索引信息
\di 显示关系列表
x 打开扩展表格式模式
\r 提供了对gsql命令的历史版本支持

二、课程作业

2.1 gsql命令连到数据库omm

-- 使用 gsql -d 数据库名 -p 端口号 来连接数据库
-- 如下所示通过26000端口连接postgres数据库
[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

image.png

2.2 查看数据库的版本及版权信息

[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000 -r
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

-- 显示openGauss数据库版本信息
openGauss=# select version();
                                                                       version                                                                        
------------------------------------------------------------------------------------------------------------------------------------------------------
 (openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)

-- 显示openGauss基于pg哪个版本开发的
openGauss=# show server_version;  
 server_version 
----------------
 9.2.4
(1 row)

-- 显示版权信息
openGauss=# \copyright
GaussDB Kernel Database Management System
Copyright (c) Huawei Technologies Co., Ltd. 2018. All rights reserved.

image.png

2.3 常见元命令使用

[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

-- \l 列出所有可用的数据库,然后退出
openGauss=# \l
                          List of databases
   Name    |  Owner  | Encoding | Collate | Ctype | Access privileges 
-----------+---------+----------+---------+-------+-------------------
 postgres  | omm     | UTF8     | C       | C     | 
 presdb    | preuser | UTF8     | C       | C     | 
 template0 | omm     | UTF8     | C       | C     | =c/omm           +
           |         |          |         |       | omm=CTc/omm
 template1 | omm     | UTF8     | C       | C     | =c/omm           +
           |         |          |         |       | omm=CTc/omm
(4 rows)

-- \conninfo 显示会话的连接信息
openGauss=# \conninfo 
You are connected to database "postgres" as user "omm" via socket in "/opt/gaussdb/tmp" at port "26000".

-- \c presdb 是切换连接到presdb数据库
openGauss=# \c presdb
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "presdb" as user "omm".

-- \du 显示数据库集簇中目前有哪些用户和角色
presdb=# \du
                                                              List of roles
 Role name |                                                    Attributes                                                    | Member of 
-----------+------------------------------------------------------------------------------------------------------------------+-----------
 omm       | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
 preuser   | Sysadmin                                                                                                         | {}

-- 同\dg 显示数据库集簇中目前有哪些用户和角色
presdb=# \dg
                                                              List of roles
 Role name |                                                    Attributes                                                    | Member of 
-----------+------------------------------------------------------------------------------------------------------------------+-----------
 omm       | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
 preuser   | Sysadmin                                                                                                         | {}

-- 显示当前数据库集簇中目前有哪些表空间
presdb=# \db
                  List of tablespaces
    Name    |  Owner  |            Location            
------------+---------+--------------------------------
 pg_default | omm     | 
 pg_global  | omm     | 
 tbs1       | preuser | /opt/gaussdb/install/data/tbs1
 tbs2       | preuser | /opt/gaussdb/install/data/tbs2
(4 rows)

-- \dn 显示当前数据库有哪些数据库模式
presdb=# \dn
     List of schemas
      Name       | Owner 
-----------------+-------
 blockchain      | omm
 cstore          | omm
 db4ai           | omm
 dbe_perf        | omm
 dbe_pldebugger  | omm
 dbe_pldeveloper | omm
 dbe_sql_util    | omm
 pkg_service     | omm
 public          | omm
 snapshot        | omm
 sqladvisor      | omm
(11 rows)

-- \d 显示当前关系列表
presdb=# \d
                                        List of relations
 Schema |       Name        |   Type   |  Owner  |                    Storage                     
--------+-------------------+----------+---------+------------------------------------------------
 public | bmsql_config      | table    | preuser | {orientation=row,compression=no}
 public | bmsql_customer    | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_district    | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_hist_id_seq | sequence | preuser | 
 public | bmsql_history     | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_item        | table    | preuser | {orientation=row,compression=no}
 public | bmsql_new_order   | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_oorder      | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_order_line  | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_stock       | table    | preuser | {orientation=row,fillfactor=80,compression=no}
 public | bmsql_warehouse   | table    | preuser | {orientation=row,fillfactor=80,compression=no}
(11 rows)

-- \d table_name 显示某个表结构
presdb=# \d bmsql_config
          Table "public.bmsql_config"
  Column   |         Type          | Modifiers 
-----------+-----------------------+-----------
 cfg_name  | character varying(30) | not null
 cfg_value | character varying(50) | 
Indexes:
    "bmsql_config_pkey" PRIMARY KEY, btree (cfg_name) TABLESPACE pg_default
Tablespace: "tbs2"

-- \di 显示关系列表
presdb=# \di 
                               List of relations
 Schema |         Name          | Type  |  Owner  |      Table       | Storage 
--------+-----------------------+-------+---------+------------------+---------
 public | bmsql_config_pkey     | index | preuser | bmsql_config     | 
 public | bmsql_customer_idx1   | index | preuser | bmsql_customer   | 
 public | bmsql_customer_pkey   | index | preuser | bmsql_customer   | 
 public | bmsql_district_pkey   | index | preuser | bmsql_district   | 
 public | bmsql_history_pkey    | index | preuser | bmsql_history    | 
 public | bmsql_item_pkey       | index | preuser | bmsql_item       | 
 public | bmsql_new_order_pkey  | index | preuser | bmsql_new_order  | 
 public | bmsql_oorder_idx1     | index | preuser | bmsql_oorder     | 
 public | bmsql_oorder_pkey     | index | preuser | bmsql_oorder     | 
 public | bmsql_order_line_pkey | index | preuser | bmsql_order_line | 
 public | bmsql_stock_pkey      | index | preuser | bmsql_stock      | 
 public | bmsql_warehouse_pkey  | index | preuser | bmsql_warehouse  | 
(12 rows)

-- \d index_name 显示该索引结构
presdb=# \d bmsql_customer_idx1
      Index "public.bmsql_customer_idx1"
 Column  |         Type          | Definition 
---------+-----------------------+------------
 c_w_id  | integer               | c_w_id
 c_d_id  | integer               | c_d_id
 c_last  | character varying(16) | c_last
 c_first | character varying(16) | c_first
btree, for table "public.bmsql_customer"

2.4 使用两种方法连到postgres数据库

可以使用gsql -d postgres 或 通过 \c postgres来连接到postres数据库

-- 通过gsql -d postgres来连接到postgres数据库
[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# \q

[omm@opengauss-node1 ~]$ gsql -d presdb -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

-- 通过 \c postgres 来连接到postgres数据库
presdb=# \c postgres
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "postgres" as user "omm".

image.png

2.5 测试gsql中的默认事务自动提交功能

openGauss在安装时默认是开启了事务自动提交功能,但可以在会话级关闭事务自动提交。

[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

-- 注意 AUTOCOMMIT 一定要大写
openGauss=# show AUTOCOMMIT;  --显示数据库开启了事务自动提交功能
 autocommit 
------------
 on
(1 row)

openGauss=# \set AUTOCOMMIT off
openGauss=# 
openGauss=# show AUTOCOMMIT;  -- 通过该方式查看到的autocommit仍然是on
 autocommit 
------------
 on
(1 row)

openGauss=# \echo :AUTOCOMMIT  -- 通过该方式可看到事务提交已关闭
off

image.png

2.5.1 测试事务自动提交

[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# show AUTOCOMMIT;
 autocommit 
------------
 on
(1 row)

openGauss=# CREATE TABLE customer_t
openGauss-# (  c_customer_sk             integer,   
openGauss(#  c_customer_id             char(5),    
openGauss(#  c_first_name              char(6),    
openGauss(#  c_last_name               char(8) 
openGauss(# ) ;
CREATE TABLE
openGauss=# INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES (3769, 5, 'Grace','White');
INSERT 0 1
openGauss=# \set AUTOCOMMIT off  -- 关闭事务提交
openGauss=# \echo :AUTOCOMMIT
off
openGauss=# select * from customer_t;  --仍可以查询到之前提交的数据
 c_customer_sk | c_customer_id | c_first_name | c_last_name 
---------------+---------------+--------------+-------------
          3769 | 5             | Grace        | White   
(1 row)

image.png

2.5.2 测试事务回滚

[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# select * from customer_t;
ERROR:  relation "customer_t" does not exist on dn_6001_6002
LINE 1: select * from customer_t;
                      ^
openGauss=# show AUTOCOMMIT;
 autocommit 
------------
 on
(1 row)

openGauss=# \echo :AUTOCOMMIT
on
openGauss=# \set AUTOCOMMIT off
openGauss=# \echo :AUTOCOMMIT
off
openGauss=# CREATE TABLE customer_t
openGauss-# (  c_customer_sk             integer,   
openGauss(#  c_customer_id             char(5),    
openGauss(#  c_first_name              char(6),    
openGauss(#  c_last_name               char(8) 
openGauss(# ) ;
CREATE TABLE
openGauss=# INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES (3769, 5, 'Grace','White');
INSERT 0 1
openGauss=# ROLLBACK;
ROLLBACK
openGauss=# \d customer_t
Did not find any relation named "customer_t".
openGauss=# select * from customer_t;
ERROR:  relation "customer_t" does not exist on dn_6001_6002
LINE 1: select * from customer_t;
                      ^
openGauss=# 
# 通过上述实验,当关闭了事务自动提交功能,执行ROLLBACK回滚,是DDL和DML都被回滚了。

image.png

2.6 测试手动事务提交

2.6.1 测试关闭事务自动提交进行手动提交

openGauss=# show AUTOCOMMIT;
 autocommit 
------------
 on
(1 row)

openGauss=# \echo :AUTOCOMMIT
on
openGauss=# \set AUTOCOMMIT off
openGauss=# \echo :AUTOCOMMIT
off
openGauss=# CREATE TABLE customer_t
openGauss-# (  c_customer_sk             integer,   
openGauss(#  c_customer_id             char(5),    
openGauss(#  c_first_name              char(6),    
openGauss(#  c_last_name               char(8) 
openGauss(# ) ;
CREATE TABLE
openGauss=# INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES    
openGauss-# (6885, 1, 'Joes', 'Hunter'),    
openGauss-# (4321, 2, 'Lily','Carter'),    
openGauss-# (9527, 3, 'James', 'Cook'),
openGauss-# (9500, 4, 'Lucy', 'Baker');
INSERT 0 4
openGauss=# select * from customer_t;
 c_customer_sk | c_customer_id | c_first_name | c_last_name 
---------------+---------------+--------------+-------------
          6885 | 1             | Joes         | Hunter  
          4321 | 2             | Lily         | Carter  
          9527 | 3             | James        | Cook    
          9500 | 4             | Lucy         | Baker   
(4 rows)

openGauss=# commit;
COMMIT
openGauss=# select * from customer_t;
 c_customer_sk | c_customer_id | c_first_name | c_last_name 
---------------+---------------+--------------+-------------
          6885 | 1             | Joes         | Hunter  
          4321 | 2             | Lily         | Carter  
          9527 | 3             | James        | Cook    
          9500 | 4             | Lucy         | Baker   
(4 rows)

openGauss=# rollback;
ROLLBACK
openGauss=# select * from customer_t;
 c_customer_sk | c_customer_id | c_first_name | c_last_name 
---------------+---------------+--------------+-------------
          6885 | 1             | Joes         | Hunter  
          4321 | 2             | Lily         | Carter  
          9527 | 3             | James        | Cook    
          9500 | 4             | Lucy         | Baker   
(4 rows)
-- 但关闭了事务自动提交,手动执行了commit,即使之后再执行rollback,提交的事务也不会被回滚。

image.png

2.6.2 测试START TRANSACTION

START TRANSACTION立即启动一个事务,而不管当前的提交模式设置如何。
无论当前的提交模式设置如何,以START transaction开始的事务必须通过发出显式COMMIT或ROLLBACK来结束

[omm@opengauss-node1 ~]$ gsql -d postgres -p 26000
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

openGauss=# show AUTOCOMMIT;
 autocommit 
------------
 on
(1 row)

openGauss=# \echo :AUTOCOMMIT
on
openGauss=# select * from customer_t;
ERROR:  relation "customer_t" does not exist on dn_6001_6002
LINE 1: select * from customer_t;
                      ^
openGauss=# START TRANSACTION;
START TRANSACTION
openGauss=# CREATE TABLE customer_t
openGauss-# (  c_customer_sk             integer,   
openGauss(#  c_customer_id             char(5),    
openGauss(#  c_first_name              char(6),    
openGauss(#  c_last_name               char(8) 
openGauss(# ) ;
CREATE TABLE
openGauss=# INSERT INTO customer_t (c_customer_sk, c_customer_id, c_first_name,c_last_name) VALUES    
openGauss-# (6885, 1, 'Joes', 'Hunter'),    
openGauss-# (4321, 2, 'Lily','Carter'),    
openGauss-# (9527, 3, 'James', 'Cook'),
openGauss-# (9500, 4, 'Lucy', 'Baker');
INSERT 0 4
openGauss=# select * from customer_t;
 c_customer_sk | c_customer_id | c_first_name | c_last_name 
---------------+---------------+--------------+-------------
          6885 | 1             | Joes         | Hunter  
          4321 | 2             | Lily         | Carter  
          9527 | 3             | James        | Cook    
          9500 | 4             | Lucy         | Baker   
(4 rows)

openGauss=# ROLLBACK;
ROLLBACK
openGauss=# select * from customer_t;
ERROR:  relation "customer_t" does not exist on dn_6001_6002
LINE 1: select * from customer_t;
                      ^
-- 通过以上测试,可以看到即使开启了事务自动提交功能,当执行START TRANSACTION,执行rollback,仍然可以回滚当前执行的事务。

image.png

2.7 了解gsql相关帮助

通过gsql --help、-h或-? 可以获取gsql的相关帮助信息

openGauss=# \h
Available help:
  ABORT                             ALTER SEQUENCE                    COMMIT                            CREATE RESOURCE POOL              DROP APP WORKLOAD GROUP MAPPING   DROP SEQUENCE                     PURGE SNAPSHOT
  ALTER APP WORKLOAD GROUP          ALTER SERVER                      COMMIT PREPARED                   CREATE ROLE                       DROP AUDIT POLICY                 DROP SERVER                       REASSIGN OWNED
  ALTER APP WORKLOAD GROUP MAPPING  ALTER SESSION                     COPY                              CREATE ROW LEVEL SECURITY POLICY  DROP CLIENT MASTER KEY            DROP SUBSCRIPTION                 REFRESH MATERIALIZED VIEW
  ALTER AUDIT POLICY                ALTER SUBSCRIPTION                CREATE APP WORKLOAD GROUP         CREATE SCHEMA                     DROP COLUMN ENCRYPTION KEY        DROP SYNONYM                      REINDEX
  ALTER DATA SOURCE                 ALTER SYNONYM                     CREATE APP WORKLOAD GROUP MAPPING CREATE SEQUENCE                   DROP DATA SOURCE                  DROP TABLE                        REPLACE
  ALTER DATABASE                    ALTER SYSTEM KILL SESSION         CREATE AUDIT POLICY               CREATE SERVER                     DROP DATABASE                     DROP TABLESPACE                   RESET
  ALTER DEFAULT PRIVILEGES          ALTER SYSTEM SET                  CREATE BARRIER                    CREATE SNAPSHOT AS                DROP DIRECTORY                    DROP TEXT SEARCH CONFIGURATION    REVOKE
  ALTER DIRECTORY                   ALTER TABLE                       CREATE CLIENT MASTER KEY          CREATE SNAPSHOT FROM              DROP EXTENSION                    DROP TEXT SEARCH DICTIONARY       ROLLBACK
  ALTER EXTENSION                   ALTER TABLE PARTITION             CREATE COLUMN ENCRYPTION KEY      CREATE SUBSCRIPTION               DROP FOREIGN TABLE                DROP TRIGGER                      ROLLBACK PREPARED
  ALTER FOREIGN TABLE               ALTER TABLE SUBPARTITION          CREATE DATA SOURCE                CREATE SYNONYM                    DROP FUNCTION                     DROP TYPE                         SAMPLE SNAPSHOT
  ALTER FOREIGN TABLE FOR HDFS      ALTER TABLESPACE                  CREATE DATABASE                   CREATE TABLE                      DROP GLOBAL CONFIGURATION         DROP USER                         SAVEPOINT
  ALTER FUNCTION                    ALTER TEXT SEARCH CONFIGURATION   CREATE DIRECTORY                  CREATE TABLE AS                   DROP GROUP                        DROP VIEW                         SELECT
  ALTER GLOBAL CONFIGURATION        ALTER TEXT SEARCH DICTIONARY      CREATE EXTENSION                  CREATE TABLE PARTITION            DROP INDEX                        DROP WEAK PASSWORD DICTIONARY     SELECT INTO
  ALTER GROUP                       ALTER TRIGGER                     CREATE FOREIGN TABLE              CREATE TABLE SUBPARTITION         DROP MASKING POLICY               DROP WORKLOAD GROUP               SET
  ALTER INDEX                       ALTER TYPE                        CREATE FUNCTION                   CREATE TABLESPACE                 DROP MATERIALIZED VIEW            END                               SET CONSTRAINTS
  ALTER LARGE OBJECT                ALTER USER                        CREATE GROUP                      CREATE TEXT SEARCH CONFIGURATION  DROP MODEL                        EXECUTE                           SET ROLE
  ALTER MASKING POLICY              ALTER VIEW                        CREATE INDEX                      CREATE TEXT SEARCH DICTIONARY     DROP NODE                         EXECUTE DIRECT                    SET SESSION AUTHORIZATION
  ALTER MATERIALIZED VIEW           ALTER WORKLOAD GROUP              CREATE LANGUAGE                   CREATE TRIGGER                    DROP NODE GROUP                   EXPLAIN                           SET TRANSACTION
  ALTER NODE                        ANALYSE                           CREATE MASKING POLICY             CREATE TYPE                       DROP OPERATOR                     FETCH                             SHOW
  ALTER NODE GROUP                  ANALYZE                           CREATE MATERIALIZED VIEW          CREATE USER                       DROP OWNED                        GRANT                             START TRANSACTION
  ALTER OPERATOR                    ANONYMOUS BLOCK                   CREATE MODEL                      CREATE VIEW                       DROP PACKAGE                      INSERT                            TIMECAPSULE TABLE
  ALTER PACKAGE                     ARCHIVE SNAPSHOT                  CREATE NODE                       CREATE WEAK PASSWORD DICTIONARY   DROP PACKAGE BODY                 LOCK                              TRUNCATE
  ALTER PROCEDURE                   BEGIN                             CREATE NODE GROUP                 CREATE WORKLOAD GROUP             DROP PROCEDURE                    MERGE                             UPDATE
  ALTER PUBLICATION                 CALL                              CREATE OPERATOR                   CURSOR                            DROP PUBLICATION                  MOVE                              VACUUM
  ALTER RESOURCE LABEL              CHECKPOINT                        CREATE PACKAGE                    DEALLOCATE                        DROP RESOURCE LABEL               PREDICT BY                        VALUES
  ALTER RESOURCE POOL               CLEAN CONNECTION                  CREATE PACKAGE BODY               DECLARE                           DROP RESOURCE POOL                PREPARE                           
  ALTER ROLE                        CLOSE                             CREATE PROCEDURE                  DELETE                            DROP ROLE                         PREPARE TRANSACTION               
  ALTER ROW LEVEL SECURITY POLICY   CLUSTER                           CREATE PUBLICATION                DO                                DROP ROW LEVEL SECURITY POLICY    PUBLISH SNAPSHOT                  
  ALTER SCHEMA                      COMMENT                           CREATE RESOURCE LABEL             DROP APP WORKLOAD GROUP           DROP SCHEMA                       PURGE   

openGauss=# \?
General
  \copyright             show openGauss usage and distribution terms
  \g [FILE] or ;         execute query (and send results to file or |pipe)
  \h(\help) [NAME]              help on syntax of SQL commands, * for all commands
  \parallel [on [num]|off] toggle status of execute (currently off)
  \q                     quit gsql

Query Buffer
  \e [FILE] [LINE]       edit the query buffer (or file) with external editor
  \ef [FUNCNAME [LINE]]  edit function definition with external editor
  \p                     show the contents of the query buffer
  \r                     reset (clear) the query buffer
  \w FILE                write query buffer to file

Input/Output
  \copy ...              perform SQL COPY with data stream to the client host
  \echo [STRING]         write string to standard output
  \i FILE                execute commands from file
  \i+ FILE KEY           execute commands from encrypted file
  \ir FILE               as \i, but relative to location of current script
  \ir+ FILE KEY          as \i+, but relative to location of current script
  \o [FILE]              send all query results to file or |pipe
  \qecho [STRING]        write string to query output stream (see \o)

Informational
  (options: S = show system objects, + = additional detail)
  \d[S+]                 list tables, views, and sequences
  \d[S+]  NAME           describe table, view, sequence, or index

三、课程总结

通过本课程的学习,加深了对gsql知识的掌握,同时也让我对openGauss的事务提交有了初步的理解。想要更深入的掌握这些知识点,还是要通过不断的测试来充分理解其含义。

最后修改时间:2022-11-25 16:56:17
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论