[openGauss 学废系列]- openGauss学习笔记整理 - 熟练掌握gsql工具的使用

news/2024/12/17 19:25:04/

一、学习目标

这节课是本次实训第二节课程,本次课的重点是熟练掌握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=VALUEset gsql variable NAME to VALUE-V, --version                     output version information, then exit-X, --no-gsqlrc                   do not read startup file (~/.gsqlrc)-1 ("one"), --single-transactionexecute command file as a single transaction-?, --help                        show this help, then exitInput 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=STRINGset 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=STRINGset 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-zeroset field separator to zero byte-0, --record-separator-zeroset record separator to zero byte-2, --pipeline                    use pipeline to pass the password, forbidden to use in terminalmust use with -c or -fConnection 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 userFor 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显示数据库集簇中目前有哪些用户和角色
\dgdg用法同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=# \lList of databasesName    |  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/ommtemplate1 | 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=# \duList of rolesRole name |                                                    Attributes                                                    | Member of 
-----------+------------------------------------------------------------------------------------------------------------------+-----------omm       | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}preuser   | Sysadmin                                                                                                         | {}-- 同\dg 显示数据库集簇中目前有哪些用户和角色
presdb=# \dgList of rolesRole name |                                                    Attributes                                                    | Member of 
-----------+------------------------------------------------------------------------------------------------------------------+-----------omm       | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}preuser   | Sysadmin                                                                                                         | {}-- 显示当前数据库集簇中目前有哪些表空间
presdb=# \dbList of tablespacesName    |  Owner  |            Location            
------------+---------+--------------------------------pg_default | omm     | pg_global  | omm     | tbs1       | preuser | /opt/gaussdb/install/data/tbs1tbs2       | preuser | /opt/gaussdb/install/data/tbs2
(4 rows)-- \dn 显示当前数据库有哪些数据库模式
presdb=# \dnList of schemasName       | Owner 
-----------------+-------blockchain      | ommcstore          | ommdb4ai           | ommdbe_perf        | ommdbe_pldebugger  | ommdbe_pldeveloper | ommdbe_sql_util    | ommpkg_service     | ommpublic          | ommsnapshot        | ommsqladvisor      | omm
(11 rows)-- \d 显示当前关系列表
presdb=# \dList of relationsSchema |       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_configTable "public.bmsql_config"Column   |         Type          | Modifiers 
-----------+-----------------------+-----------cfg_name  | character varying(30) | not nullcfg_value | character varying(50) | 
Indexes:"bmsql_config_pkey" PRIMARY KEY, btree (cfg_name) TABLESPACE pg_default
Tablespace: "tbs2"-- \di 显示关系列表
presdb=# \di List of relationsSchema |         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_idx1Index "public.bmsql_customer_idx1"Column  |         Type          | Definition 
---------+-----------------------+------------c_w_id  | integer               | c_w_idc_d_id  | integer               | c_d_idc_last  | character varying(16) | c_lastc_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仍然是onautocommit 
------------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 SNAPSHOTALTER APP WORKLOAD GROUP          ALTER SERVER                      COMMIT PREPARED                   CREATE ROLE                       DROP AUDIT POLICY                 DROP SERVER                       REASSIGN OWNEDALTER APP WORKLOAD GROUP MAPPING  ALTER SESSION                     COPY                              CREATE ROW LEVEL SECURITY POLICY  DROP CLIENT MASTER KEY            DROP SUBSCRIPTION                 REFRESH MATERIALIZED VIEWALTER AUDIT POLICY                ALTER SUBSCRIPTION                CREATE APP WORKLOAD GROUP         CREATE SCHEMA                     DROP COLUMN ENCRYPTION KEY        DROP SYNONYM                      REINDEXALTER DATA SOURCE                 ALTER SYNONYM                     CREATE APP WORKLOAD GROUP MAPPING CREATE SEQUENCE                   DROP DATA SOURCE                  DROP TABLE                        REPLACEALTER DATABASE                    ALTER SYSTEM KILL SESSION         CREATE AUDIT POLICY               CREATE SERVER                     DROP DATABASE                     DROP TABLESPACE                   RESETALTER DEFAULT PRIVILEGES          ALTER SYSTEM SET                  CREATE BARRIER                    CREATE SNAPSHOT AS                DROP DIRECTORY                    DROP TEXT SEARCH CONFIGURATION    REVOKEALTER DIRECTORY                   ALTER TABLE                       CREATE CLIENT MASTER KEY          CREATE SNAPSHOT FROM              DROP EXTENSION                    DROP TEXT SEARCH DICTIONARY       ROLLBACKALTER EXTENSION                   ALTER TABLE PARTITION             CREATE COLUMN ENCRYPTION KEY      CREATE SUBSCRIPTION               DROP FOREIGN TABLE                DROP TRIGGER                      ROLLBACK PREPAREDALTER FOREIGN TABLE               ALTER TABLE SUBPARTITION          CREATE DATA SOURCE                CREATE SYNONYM                    DROP FUNCTION                     DROP TYPE                         SAMPLE SNAPSHOTALTER FOREIGN TABLE FOR HDFS      ALTER TABLESPACE                  CREATE DATABASE                   CREATE TABLE                      DROP GLOBAL CONFIGURATION         DROP USER                         SAVEPOINTALTER FUNCTION                    ALTER TEXT SEARCH CONFIGURATION   CREATE DIRECTORY                  CREATE TABLE AS                   DROP GROUP                        DROP VIEW                         SELECTALTER GLOBAL CONFIGURATION        ALTER TEXT SEARCH DICTIONARY      CREATE EXTENSION                  CREATE TABLE PARTITION            DROP INDEX                        DROP WEAK PASSWORD DICTIONARY     SELECT INTOALTER GROUP                       ALTER TRIGGER                     CREATE FOREIGN TABLE              CREATE TABLE SUBPARTITION         DROP MASKING POLICY               DROP WORKLOAD GROUP               SETALTER INDEX                       ALTER TYPE                        CREATE FUNCTION                   CREATE TABLESPACE                 DROP MATERIALIZED VIEW            END                               SET CONSTRAINTSALTER LARGE OBJECT                ALTER USER                        CREATE GROUP                      CREATE TEXT SEARCH CONFIGURATION  DROP MODEL                        EXECUTE                           SET ROLEALTER MASKING POLICY              ALTER VIEW                        CREATE INDEX                      CREATE TEXT SEARCH DICTIONARY     DROP NODE                         EXECUTE DIRECT                    SET SESSION AUTHORIZATIONALTER MATERIALIZED VIEW           ALTER WORKLOAD GROUP              CREATE LANGUAGE                   CREATE TRIGGER                    DROP NODE GROUP                   EXPLAIN                           SET TRANSACTIONALTER NODE                        ANALYSE                           CREATE MASKING POLICY             CREATE TYPE                       DROP OPERATOR                     FETCH                             SHOWALTER NODE GROUP                  ANALYZE                           CREATE MATERIALIZED VIEW          CREATE USER                       DROP OWNED                        GRANT                             START TRANSACTIONALTER OPERATOR                    ANONYMOUS BLOCK                   CREATE MODEL                      CREATE VIEW                       DROP PACKAGE                      INSERT                            TIMECAPSULE TABLEALTER PACKAGE                     ARCHIVE SNAPSHOT                  CREATE NODE                       CREATE WEAK PASSWORD DICTIONARY   DROP PACKAGE BODY                 LOCK                              TRUNCATEALTER PROCEDURE                   BEGIN                             CREATE NODE GROUP                 CREATE WORKLOAD GROUP             DROP PROCEDURE                    MERGE                             UPDATEALTER PUBLICATION                 CALL                              CREATE OPERATOR                   CURSOR                            DROP PUBLICATION                  MOVE                              VACUUMALTER RESOURCE LABEL              CHECKPOINT                        CREATE PACKAGE                    DEALLOCATE                        DROP RESOURCE LABEL               PREDICT BY                        VALUESALTER 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 gsqlQuery 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 fileInput/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的事务提交有了初步的理解。想要更深入的掌握这些知识点,还是要通过不断的测试来充分理解其含义。


http://www.ppmy.cn/news/1555935.html

相关文章

【AIStarter】告别复杂转换 - MinerU整合包实现PDF到Markdown的无缝转变

在数字化时代,信息的传递与共享变得愈发重要。文档格式之间的转换成为了日常工作中不可或缺的一部分。为了满足用户对高效工作流程的需求,新版MinerU整合包应运而生,它不仅简化了从PDF到Markdown的转换过程,还为用户带来了前所未有…

【Linux网络】网络基础:传输层UDP/TCP协议(一)

📝个人主页🌹:Eternity._ ⏩收录专栏⏪:Linux “ 登神长阶 ” 🌹🌹期待您的关注 🌹🌹 ❀ 传输层UDP/TCP协议 📒端口号📜UDP协议UDP协议端格式UDP的特点UDP的缓…

【后端面试总结】什么是CAP原理

CAP原理是分布式系统设计中的一个重要理论,最早由Eric Brewer在2000年提出,后来由Nancy Lynch等人进行了证明。CAP原理中的“CAP”分别指的是一致性(Consistency)、可用性(Availability)和分区容错性&#…

(笔记)解决select下拉框默认选中selected属性不起作用问题

在 vue3 中使用 HTML原生开发,想给 select 下拉框选中 selected 属性不起作用。这是因为 vue3中使用了 Composition API(组合式 api),而 Composition API 中的响应式数据是独立的,不会自动更新到 DOM 中。可以使用 v-m…

通过 css 渲染一个如图所示的晶格状画布背景

<!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>Document</title><style>/* 一个晶格状…

处理idea+tomcat的中文乱码

1:tomcat的日志的配置文件中 java.util.logging.ConsoleHandler.encoding UTF-8 java.util.logging.FileHandler.encoding UTF-8 2:idea 的settings中的file Encodings 3:idea中配置tomcat的地方 暂且我就是想到这些地方,如果还有其他地方,我会在添加的

流程图(一)利用python绘制弦图

流程图&#xff08;一&#xff09;利用python绘制弦图 弦图&#xff08;Chord diagram&#xff09;简介 数据围绕一个圆呈放射状排列&#xff0c;显示不同实体之间的相互关系&#xff0c;这既是弦图。弦图通过每个圆弧的大小比例表示连接分配数值&#xff0c;可以用颜色将数据…

阿里云服务器手动搭建WordPress【官方文档注意事项】

这是官方文档 注意事项 先配LNMP&#xff0c;我的上一篇文章到这里发现&#xff0c;没有基于ubuntu的教程&#xff0c;所以创建服务器时选择centos在官方文档第四步“下载WordPress&#xff0c;并移动至网站根目录”中&#xff0c;首先它让cd /usr/share/nginx/html&#xff…