Help Center/ GaussDB/ Tool Guide(Centralized_8.x)/ gsql/ Obtaining Help Information
Updated on 2024-06-07 GMT+08:00

Obtaining Help Information

Procedure

  • When connecting to the database, run the following command to obtain the help information:
    gsql --help

    The following help 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: "omm")
      -f, --file=<FILE_NAME>      execute commands from file, then exit
    ......
  • When connecting to the database, run the following command to obtain the help information:
    help

    The following help 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

Examples

  1. Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in the Developer Guide.
  2. View the gsql help information. For details, see Table 1.

    Table 1 gsql online help

    Description

    Example

    Query the copyright.

    \copyright

    View help information about SQL statements supported by GaussDB.

    View help information about SQL statements supported by GaussDB.

    For example, view all SQL statements supported by GaussDB.

    1
    2
    3
    4
    5
    6
    gaussdb=# \h
    Available help:
      ABORT                            
      ALTER APP WORKLOAD GROUP
      ALTER APP WORKLOAD GROUP MAPPING                  
    ... ...
    

    For example, view parameters of the CREATE DATABASE command:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    gaussdb=# \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 the help information about gsql commands.

    For example, view commands supported by gsql.

    1
    2
    3
    4
    5
    6
    7
    gaussdb=# \?
    General
      \copyright             show GaussDB Kernel 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
    ... ...