4.使用两种方法,连到postgres数据库中
方法1:
omm@modb:~$ gsql -r
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type “help” for help.omm=# \c postgres
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database “postgres” as user “omm”.
openGauss=#
方法2:
omm@modb:~$ gsql -d postgres -p 5432 -r
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type “help” for help.openGauss=#
5.测试gsql中的默认事务自动提交功能
openGauss=# show autocommit;
autocommit
------------
on
(1 row)
openGauss=# create table customer_new as select * from customer_t;
INSERT 0 0
openGauss=# \q
omm@modb:~$ gsql -d postgres -p 5432 -r
gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type “help” for help.openGauss=# \dt
List of relations
Schema | Name | Type | Owner | Storage
--------±-------------±------±------±---------------------------------
public | customer_new | table | omm | {orientation=row,compression=no}
public | customer_t | table | omm | {orientation=row,compression=no}
public | t1 | table | omm | {orientation=row,compression=no}
(3 rows)
6.测试gsql中的事务手动提交功能
openGauss=# \set AUTOCOMMIT off
openGauss=# show AUTOCOMMIT;
autocommit
------------
on
(1 row)openGauss=# select * from customer_t;
c_customer_sk | c_customer_id | c_first_name | c_last_name
---------------±--------------±-------------±------------
3769 | 5 | Grace | White
(1 row)openGauss=# delete from customer_t;
DELETE 1
openGauss=# select * from customer_t;openGauss=# c_customer_sk | c_customer_id | c_first_name | c_last_name
---------------±--------------±-------------±------------
(0 rows)openGauss=# rollback;
ROLLBACK
openGauss=# select * from customer_t;
(1 row)openGauss=# c_customer_sk | c_customer_id | c_first_name | c_last_name
---------------±--------------±-------------±------------
3769 | 5 | Grace | White
7.了解gsql相关帮助
omm@modb:~$ 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”)
openGauss=# \h
Available help:
ABORT CREATE DATA SOURCE DROP NODE GROUP
ALTER APP WORKLOAD GROUP CREATE DATABASE DROP OPERATOR
ALTER APP WORKLOAD GROUP MAPPING CREATE DIRECTORY DROP OWNED
ALTER AUDIT POLICY CREATE EXTENSION DROP PACKAGE
ALTER DATA SOURCE CREATE FOREIGN TABLE DROP PACKAGE BODY
ALTER DATABASE CREATE FUNCTION DROP PROCEDURE




