What\'s the equivalent to show tables
(from MySQL) in PostgreSQL?
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' ;
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
use only see a tables
=> \dt
if want to see schema tables
=>\dt+
if you want to see specific schema tables
=>\dt schema_name.*
select
*
from
pg_catalog.pg_tables
where
schemaname != 'information_schema'
and schemaname != 'pg_catalog';
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+
\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.