获取帮助

操作步骤

  • 连接数据库时,可以使用如下命令获取帮助信息。

    1. gsql --help

    显示如下帮助信息:

    1. ......
    2. Usage:
    3. gsql [OPTION]... [DBNAME [USERNAME]]
    4. General options:
    5. -c, --command=COMMAND run only single command (SQL or internal) and exit
    6. -d, --dbname=DBNAME database name to connect to (default: "postgres")
    7. -f, --file=FILENAME execute commands from file, then exit
    8. ......
  • 连接到数据库后,可以使用如下命令获取帮助信息。

    1. help

    显示如下帮助信息:

    1. You are using gsql, the command-line interface to gaussdb.
    2. Type: \copyright for distribution terms
    3. \h for help with SQL commands
    4. \? for help with gsql commands
    5. \g or terminate with semicolon to execute query
    6. \q to quit

任务示例

  1. 使用如下命令连接数据库。

    1. gsql -d postgres -p 5432

    postgres为需要连接的数据库名称,5432为数据库主节点的端口号。

    连接成功后,系统显示类似如下信息:

    1. gsql ((openGauss x.x build 290d125f) compiled at 2020-05-08 02:59:43 commit 2143 last mr 131
    2. Non-SSL connection (SSL connection is recommended when requiring high-security)
    3. Type "help" for help.
    4. postgres=#
  2. 查看gsql的帮助信息。具体执行命令请参见表1

    表 1 使用gsql联机帮助

    描述

    示例

    查看版权信息

    \copyright

    查看openGauss支持的SQL语句的帮助

    查看openGauss支持的SQL语句的帮助

    例如,查看openGauss支持的所有SQL语句:

    1. postgres=# \h
    2. Available help:
    3. ABORT
    4. ALTER APP WORKLOAD GROUP

    例如,查看CREATE DATABASE命令的参数可使用下面的命令:

    1. postgres=# \help CREATE DATABASE
    2. Command: CREATE DATABASE
    3. Description: create a new database
    4. Syntax:
    5. CREATE DATABASE database_name
    6. [ [ WITH ] {[ OWNER [=] user_name ]|
    7. [ TEMPLATE [=] template ]|
    8. [ ENCODING [=] encoding ]|
    9. [ LC_COLLATE [=] lc_collate ]|
    10. [ LC_CTYPE [=] lc_ctype ]|
    11. [ DBCOMPATIBILITY [=] compatibility_type ]|
    12. [ TABLESPACE [=] tablespace_name ]|
    13. [ CONNECTION LIMIT [=] connlimit ]}[…] ];

    查看gsql命令的帮助

    例如,查看gsql支持的命令:

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