Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Show tables in PostgreSQL

Tags:

postgresql

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

like image 230
flybywire Avatar asked Apr 20 '09 19:04

flybywire


People also ask

How can I see tables in database?

To use the SHOW TABLES command, you need to log on to the MySQL server first. On opening the MySQL Command Line Client, enter your password. Select the specific database. Run the SHOW TABLES command to see all the tables in the database that has been selected.

What is show tables command?

SHOW TABLES lists the non- TEMPORARY tables in a given database. You can also get this list using the mysqlshow db_name command. The LIKE clause, if present, indicates which table names to match.


2 Answers

From the psql command line interface,

First, choose your database

\c database_name 

Then, this shows all tables in the current schema:

\dt 

Programmatically (or from the psql interface too, of course):

SELECT * FROM pg_catalog.pg_tables; 

The system tables live in the pg_catalog database.

like image 157
Mihai Limbășan Avatar answered Sep 17 '22 16:09

Mihai Limbășan


Login as superuser:

sudo -u postgres psql 

You can list all databases and users by \l command, (list other commands by \?).

Now if you want to see other databases you can change user/database by \c command like \c template1, \c postgres postgres and use \d, \dt or \dS to see tables/views/etc.

like image 40
JLarky Avatar answered Sep 16 '22 16:09

JLarky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!