PostgreSQL: Show tables in PostgreSQL

后端 未结 24 2668
醉梦人生
醉梦人生 2020-11-28 16:58

What\'s the equivalent to show tables (from MySQL) in PostgreSQL?

24条回答
  •  时光说笑
    2020-11-28 17:32

    Note that \dt alone will list tables in the public schema of the database you're using. I like to keep my tables in separate schemas, so the accepted answer didn't work for me.

    To list all tables within a specific schema, I needed to:

    1) Connect to the desired database:

    psql mydb
    

    2) Specify the schema name I want to see tables for after the \dt command, like this:

    \dt myschema.*
    

    This shows me the results I'm interested in:

                   List of relations
     Schema   |       Name      | Type  |  Owner   
    ----------+-----------------+-------+----------
     myschema | users           | table | postgres
     myschema | activity        | table | postgres
     myschema | roles           | table | postgres
    

提交回复
热议问题