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

Instruction

Downloading and Installing gsql and Using It to Connect to the Cluster Database

For details about how to download and install gsql and connect it to the cluster database, see "Using the gsql CLI Client to Connect to a Cluster" in the Data Warehouse Service (DWS) Management Guide.

Example

The example shows how to spread a command over several lines of input. Pay attention to prompt changes:

1
2
3
4
5
postgres=# CREATE TABLE HR.areaS(
postgres(# area_ID   NUMBER,
postgres(# area_NAME VARCHAR2(25)
postgres-# )tablespace EXAMPLE;
CREATE TABLE

View the table definition.

1
2
3
4
5
6
\d HR.areaS
               Table "hr.areas"
  Column   |         Type          | Modifiers 
-----------+-----------------------+-----------
 area_id   | numeric               | not null
 area_name | character varying(25) | 

Insert four lines of data into HR.areaS.

1
2
3
4
5
6
7
8
INSERT INTO HR.areaS (area_ID, area_NAME) VALUES (1, 'Wood');
INSERT 0 1
INSERT INTO HR.areaS (area_ID, area_NAME) VALUES (2, 'Lake');
INSERT 0 1
INSERT INTO HR.areaS (area_ID, area_NAME) VALUES (3, 'Desert');
INSERT 0 1
INSERT INTO HR.areaS (area_ID, area_NAME) VALUES (4, 'Iron');
INSERT 0 1

Change the prompt.

1
2
\set PROMPT1 '%n@%m %~%R%#'
dbadmin@[local] postgres=#

View the table.

1
2
3
4
5
6
7
8
dbadmin@[local] postgres=#SELECT * FROM HR.areaS;
 area_id |       area_name        
---------+------------------------
       1 | Wood
       4 | Iron
       2 | Lake
       3 | Desert
(4 rows)

Run the \pset command to display the table in different ways.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dbadmin@[local] postgres=#\pset border 2
Border style is 2.
dbadmin@[local] postgres=#SELECT * FROM HR.areaS;
+---------+------------------------+
| area_id |       area_name        |
+---------+------------------------+
|       1 | Wood                 |
|       2 | Lake               |
|       3 | Desert                   |
|       4 | Iron |
+---------+------------------------+
(4 rows)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dbadmin@[local] postgres=#\pset border 0
Border style is 0.
dbadmin@[local] postgres=#SELECT * FROM HR.areaS;
area_id       area_name        
------- ----------------------
      1 Wood
      2 Lake
      3 Desert
      4 Iron
(4 rows)

Use the meta-command.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
dbadmin@[local] postgres=#\a \t \x
Output format is unaligned.
Showing only tuples.
Expanded display is on.
dbadmin@[local] postgres=#SELECT * FROM HR.areaS;
area_id|2
area_name|Lake

area_id|1
area_name|Wood

area_id|4
area_name|Iron

area_id|3
area_name|Desert
dbadmin@[local] postgres=#