PostgreSQL: Show tables in PostgreSQL

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

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

相关标签:
24条回答
  • This SQL Query works with most of the versions of PostgreSQL and fairly simple .

    select table_name from information_schema.tables where table_schema='public' ;
    
    0 讨论(0)
  • 2020-11-28 17:35

    First you can connect with your postgres database using the postgre.app on mac or using postico. Run the following command:

    psql -h localhost -p port_number -d database_name -U user_name -W
    

    then you enter your password, this should give access to your database

    0 讨论(0)
  • 2020-11-28 17:36

    use only see a tables

    => \dt
    

    if want to see schema tables

    =>\dt+
    

    if you want to see specific schema tables

    =>\dt schema_name.* 
    
    0 讨论(0)
  • 2020-11-28 17:36
    select 
      * 
    from 
      pg_catalog.pg_tables 
    where 
      schemaname != 'information_schema' 
      and schemaname != 'pg_catalog';
    
    0 讨论(0)
  • 2020-11-28 17:36

    First of all you have to connect with your database like

    my database is ubuntu

    use this command to connect

     \c ubuntu
    

    This message will show

    "You are now connected to database "ubuntu" as user "postgres"."

    Now

    Run this command to show all tables in it

    \d+
    
    0 讨论(0)
  • 2020-11-28 17:39

    \dt (no * required) -- will list all tables for an existing database you are already connected to. Also useful to note:

    \d [table_name] -- will show all columns for a given table including type information, references and key constraints.

    0 讨论(0)
提交回复
热议问题