Show tables in PostgreSQL



  • 3 Answer(s)

    This will display all the tables in current schema using the psql command line interfaces:

    \dt
    
    

    Programmatically or using the psql interface:

    SELECT * FROM pg_catalog.pg_tables;
    
    

    The pg_catalog database in system tables.

    Answered on December 24, 2018.
    Add Comment

    Show tables in PostgreSQL:

    sudo -u postgres psql
    

    Listingout the all databases and users by \l command, list other commands by \?

    The  database can change the user database by \c command like \c template1, \c postgres postgres and use \d, \dt or \dS to see tables/views/etc.

    Answered on December 24, 2018.
    Add Comment

    The (SQL-standard) information schema query as follows:

    SELECT
      table_schema || '.' || table_name
    FROM
      information_schema.tables
    WHERE
      table_type = 'BASE TABLE'
    AND
      table_schema NOT IN ('pg_catalog', 'information_schema');
    
    Answered on December 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.