skip to Main Content

With help or h below, I could show the SQL commands as shown below:

help

Or:

h
postgres=# help
Available help:
  ABORT                            CREATE USER
  ALTER AGGREGATE                  CREATE USER MAPPING
  ALTER COLLATION                  CREATE VIEW
  ALTER CONVERSION                 DEALLOCATE
  ALTER DATABASE                   DECLARE
  ALTER DEFAULT PRIVILEGES         DELETE
  ALTER DOMAIN                     DISCARD
  ALTER EVENT TRIGGER              DO
  ALTER EXTENSION                  DROP ACCESS METHOD
  ALTER FOREIGN DATA WRAPPER       DROP AGGREGATE
  ALTER FOREIGN TABLE              DROP CAST
  ALTER FUNCTION                   DROP COLLATION
  ALTER GROUP                      DROP CONVERSION
  ALTER INDEX                      DROP DATABASE
  ALTER LANGUAGE                   DROP DOMAIN
...

Now, how can I show the backslash commands in PostgreSQL like l, dt, q, h, etc?

2

Answers


  1. Chosen as BEST ANSWER

    With ? below, you can show the backslash commands in PostgreSQL as shown below:

    ?
    
    postgres=# ?
    General
      copyright             show PostgreSQL usage and distribution terms
      crosstabview [COLUMNS] execute query and display results in crosstab
      errverbose            show most recent error message at maximum verbosity
      g [(OPTIONS)] [FILE]  execute query (and send results to file or |pipe);
                             g with no arguments is equivalent to a semicolon
      gdesc                 describe result of query, without executing it
      gexec                 execute query, then execute each value in its result
      gset [PREFIX]         execute query and store results in psql variables
      gx [(OPTIONS)] [FILE] as g, but forces expanded output mode
      q                     quit psql
      watch [SEC]           execute query every SEC seconds
    
    Help
      ? [commands]          show help on backslash commands
      ? options             show help on psql command-line options
      ? variables           show help on special variables
      h [NAME]              help on syntax of SQL commands, * for all commands
    ...
    

  2. Simply write these in your terminal
    To list databases: l
    To list tables: dt
    To quit PostgreSQL: q
    To access help: h

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search