Updated on 2023-03-17 GMT+08:00

Online Help

Procedure

  • When a database is being connected, run the following commands to obtain the help information:
    gsql --help

    The following information is displayed:

    ......
    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: "postgres")
      -f, --file=FILENAME      execute commands from file, then exit
    ......
  • After the database is connected, run the following commands to obtain the help information:
    help

    The following information is displayed:

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

Task Example

  1. View the gsql help information. For details about the commands, see Table 1.

    Table 1 gsql online help

    Description

    Example

    View copyright information.

    \copyright

    View the help information about SQL statements supported by GaussDB(DWS).

    View the help information about SQL statements supported by GaussDB(DWS).

    For example, view all SQL statements supported by GaussDB(DWS).

    1
    2
    3
    4
    5
    6
    \h
    Available help:
      ABORT                            
      ALTER DATABAE
      ALTER DATA SOURCE                 
    ... ...
    

    For example, view parameters of the CREATE DATABASE command:

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

    View help information about gsql commands.

    For example, view commands supported by gsql.

    1
    2
    3
    4
    5
    6
    7
    \?
    General
      \copyright             show PostgreSQL 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
      \q                     quit gsql
    ... ...