Updated on 2024-05-07 GMT+08:00

Viewing Data

  • Run the following command to query information about all tables in a database in the system catalog pg_tables:
    1
    gaussdb=# SELECT * FROM pg_tables;
    
  • Run the \d+ command of the gsql tool to query table attributes:
    1
    gaussdb=# \d+ customer_t1;
    
  • Run the following command to query the data volume of table customer_t1:
    1
    gaussdb=# SELECT count(*) FROM customer_t1;
    
  • Run the following command to query all data in the table customer_t1:
    1
    gaussdb=# SELECT * FROM customer_t1;
    
  • Run the following command to query only the data in the column c_customer_sk:
    1
    gaussdb=# SELECT c_customer_sk FROM customer_t1;
    
  • Run the following command to filter repeated data in the column c_customer_sk:
    1
    gaussdb=# SELECT DISTINCT( c_customer_sk ) FROM customer_t1;
    
  • Run the following command to query all data whose column c_customer_sk is 3869:
    1
    gaussdb=# SELECT * FROM customer_t1 WHERE c_customer_sk = 3869;
    
  • Run the following command to collate data based on the column c_customer_sk:
    1
    gaussdb=# SELECT * FROM customer_t1 ORDER BY c_customer_sk;