Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Command Reference

Updated on 2022-08-16 GMT+08:00

For details about gsql parameters, see Table 1, Table 2, Table 3, and Table 4.

Table 1 Common parameters

Parameter

Description

Value Range

-c, --command=COMMAND

Specifies that gsql runs a string command and then exits.

-

-C, --set-file=FILENAME

Uses the file as the command source instead of interactive input. After processing the file, gsql does not exit and continues to process other contents.

An absolute path or relative path that meets the OS path naming convention

-d, --dbname=DBNAME

Specifies the name of the database to be connected.

A character string.

-D, --dynamic-param

Controls the generation of variables and the ${} variable referencing method during SQL statement execution. For details, see Variable.

-

-f, --file=FILENAME

Specifies that files are used as the command source instead of interactively-entered commands. After the files are processed, exit from gsql. If FILENAME is - (hyphen), then standard input is read.

An absolute path or relative path that meets the OS path naming convention

-l, --list

Lists all available databases and then exits.

-

-v, --set, --variable=NAME=VALUE

Sets the gsql variable NAME to VALUE.

For details about variable examples and descriptions, see Variable.

-

-X, --no-gsqlrc

Does not read the startup file (neither the system-wide gsqlrc file nor the user's ~/.gsqlrc file).

NOTE:

The startup file is ~/.gsqlrc by default or it can be specified by the environment variable PSQLRC.

-

-1 ("one"), --single-transaction

When gsql uses the -f parameter to execute a script, START TRANSACTION and COMMIT are added to the start and end of the script, respectively, so that the script is executed as one transaction. This ensures that the script is executed successfully. If the script cannot be executed, the script is invalid.

NOTE:

If the script has used START TRANSACTION, COMMIT, and ROLLBACK, this parameter is invalid.

-

-?, --help

Displays help information about gsql CLI parameters, and exits.

-

-V, --version

Prints the gsql version and exits.

-

Table 2 Input and output parameters

Parameter

Description

Value Range

-a, --echo-all

Prints all input lines to standard output as they are read.

CAUTION:

When this parameter is used in some SQL statements, sensitive information, such as user passwords, may be disclosed. Use this parameter with caution.

-

-e, --echo-queries

Copies all SQL statements sent to the server to standard output as well.

CAUTION:

When this parameter is used in some SQL statements, sensitive information, such as user passwords, may be disclosed. Use this parameter with caution.

-

-E, --echo-hidden

Echoes the actual queries generated by \d and other backslash commands.

-

-k, --with-key=KEY

Uses gsql to decrypt imported encrypted files.

NOTICE:

For key characters, such as the single quotation mark (') or double quotation mark (") in shell commands, Linux shell checks whether the input single quotation mark (') or double quotation mark (") matches. If it does not match, Linux shell regards that the user input is unfinished and waits for more input instead of entering the gsql program.

-

-L, --log-file=FILENAME

Writes normal output destination and all query output into the FILENAME file.

CAUTION:
  • When this parameter is used in some SQL statements, sensitive information, such as user passwords, may be disclosed. Use this parameter with caution.
  • This parameter retains only the query result in the corresponding file, so that the result can be easily found and parsed by other invokers (for example, automatic O&M scripts). Logs about gsql operation are not retained.

An absolute path or relative path that meets the OS path naming convention

-m, --maintenance

Allows a cluster to be connected when a two-phase transaction is being restored.

NOTE:

The parameter is for engineers only. When this parameter is used, gsql can be connected to the standby server to check data consistency between the primary server and standby server.

-

-n, --no-libedit

Closes the command line editing.

-

-o, --output=FILENAME

Puts all query output into the FILENAME file.

An absolute path or relative path that meets the OS path naming convention

-q, --quiet

Indicates the quiet mode and no additional information will be printed.

By default, gsql displays various information.

-s, --single-step

Runs in single-step mode. This indicates that the user is prompted before each command is sent to the server. This parameter can also be used for canceling execution. This parameter can be used to debug scripts.

CAUTION:

When this parameter is used in some SQL statements, sensitive information, such as user passwords, may be disclosed. Use this parameter with caution.

-

-S, --single-line

Runs in single-row mode where a new line terminates a SQL statement in the same manner as a semicolon does.

-

Table 3 Parameters specifying output formats

Parameter

Description

Value Range

-A, --no-align

Switches to unaligned output mode.

The default output mode is aligned.

-F, --field-separator=STRING

Specifies the field separator. The default is the vertical bar (|).

-

-H, --html

Turns on the HTML tabular output.

-

-P, --pset=VAR[=ARG]

Specifies the print option in the \pset format in the command line.

NOTE:

The equal sign (=), instead of the space, is used here to separate the name and value. For example, enter -P format=latex to set the output format to LaTeX.

-

-R, --record-separator=STRING

Specifies the record separators.

-

-r

Enables the function of recording historical operations on the client.

This function is disabled by default.

-t, --tuples-only

Prints only tuples.

-

-T, --table-attr=TEXT

Specifies options to be placed within the HTML table tag.

Use this parameter with the -H,--html parameter to specify the output to the HTML format.

-

-x, --expanded

Turns on the expanded table formatting mode.

-

-z, --field-separator-zero

Sets the field separator in the unaligned output mode to be blank.

Use this parameter with the -A, --no-align parameter to switch to unaligned output mode.

-

-0, --record-separator-zero

Sets the record separator in the unaligned output mode to be blank.

Use this parameter with the -A, --no-align parameter to switch to unaligned output mode.

-

-g

Displays separators for all SQL statements and specified files.

NOTE:

The -g parameter must be configured with the -f parameter.

-

Table 4 Connection parameters

Parameter

Description

Value Range

-h, --host=HOSTNAME

Specifies the host name of the machine on which the server is running or the directory for the Unix-domain socket.

If the host name is omitted, gsql connects to the server of the local host over the Unix domain socket or over TCP/IP to connect to local host without the Unix domain socket.

-p, --port=PORT

Specifies the port number of the database server.

You can modify the default port number using the -p, --port=PORT parameter.

The default value is 8000.

-U, --username=USERNAME

Specifies the user that accesses a database.

NOTE:
  • If a user is specified to access a database using this parameter, a user password must be provided together for identity verification. You can enter the password interactively or use the -W parameter to specify a password.
  • To connect to a database, add an escape character before any dollar sign ($) in the user name.

A string. The default user is the current user that operates the system.

-W, --password=PASSWORD

Specifies a password when the -U parameter is used to connect to a remote database.

NOTE:

To connect to a database, add an escape character before any backslash (\) or back quote (`) in the password.

If this parameter is not specified but database connection requires your password, you will be prompted to enter your password in interactive mode. The maximum length of the password is 999 bytes, which is restricted by the maximum value of the GUC parameter password max length.

This parameter must meet the password complexity requirement.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback