PostgreSQL Tutorial

  • Home
  • Administration
  • Views
  • Triggers
  • Stored Procedures
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
Home / PostgreSQL Administration / PostgreSQL Show Tables

PostgreSQL Show Tables

Summary: this tutorial shows you different ways to show tables in PostgreSQL using psql tool and pg_catalog schema.

If you are coming from MySQL, you may miss the SHOW TABLES statement that displays all tables in a specific database. PostgreSQL does not provide the SHOW TABLES statement directly but give you something similar.

PostgreSQL show tables using psql

If you are using psql, you can use the following command to show tables in the current database.

1
\dt

For example, you can connect to the dvdrental database and show all tables as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Server [localhost]:
Database [postgres]: dvdrental
Port [5432]:
Username [postgres]:
psql (9.4.2)
 
dvdrental=# \dt
             List of relations
Schema |     Name      | Type  |  Owner
--------+---------------+-------+----------
public | actor         | table | postgres
public | address       | table | postgres
public | category      | table | postgres
public | city          | table | postgres
public | country       | table | postgres
public | customer      | table | postgres
public | film          | table | postgres
public | film_actor    | table | postgres
public | film_category | table | postgres
public | inventory     | table | postgres
public | language      | table | postgres
public | payment       | table | postgres
public | persons       | table | postgres
public | rental        | table | postgres
public | staff         | table | postgres
public | store         | table | postgres
(16 rows)
 
 
dvdrental=#

PostgreSQL show tables using pg_catalog schema

Another way to show tables in PostgreSQL is to use SELECT statement to query data from the PostgreSQL catalog as follows:

1
2
3
4
5
6
7
SELECT
*
FROM
pg_catalog.pg_tables
WHERE
schemaname != 'pg_catalog'
AND schemaname != 'information_schema';

postgresql show tables

We used condition in the WHERE clause to filter system tables. If you omit the WHERE clause, you will get many tables that are the system tables, which you may not want to.

Related Tutorials

  • PostgreSQL Show Databases
  • PostgreSQL Describe Table
Previous Tutorial: PostgreSQL Show Databases
Next Tutorial: PostgreSQL Describe Table

PostgreSQL Quick Start

  • What is PostgreSQL?
  • Install PostgreSQL
  • Connect to Database
  • Download PostgreSQL Sample Database
  • Load Sample Database
  • Explore Server and Database Objects

PostgreSQL Fundamentals

  • PostgreSQL Select
  • PostgreSQL Order By
  • PostgreSQL Select Distinct
  • PostgreSQL Where
  • PostgreSQL LIMIT
  • PostgreSQL IN
  • PostgreSQL Between
  • PostgreSQL Like
  • PostgreSQL Inner Join
  • PostgreSQL Left Join
  • PostgreSQL Full Outer Join
  • PostgreSQL Cross Join
  • PostgreSQL Natural Join
  • PostgreSQL Group By
  • PostgreSQL Having
  • PostgreSQL Union
  • PostgreSQL Intersect
  • PostgreSQL Except
  • PostgreSQL Subquery
  • PostgreSQL Insert
  • PostgreSQL Update
  • PostgreSQL Delete
  • PostgreSQL Data Types
  • PostgreSQL Create Table
  • PostgreSQL Alter Table
  • PostgreSQL Drop Table
  • PostgreSQL Truncate Table
  • PostgreSQL CHECK Constraint
  • PostgreSQL Not-Null Constraint
  • PostgreSQL Foreign Key
  • PostgreSQL Primary Key
  • PostgreSQL UNIQUE Constraint

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • PostgreSQL Recursive View
  • Learn PostgreSQL Recursive Query By Example
  • Creating Updatable Views Using the WITH CHECK OPTION Clause
  • PostgreSQL Upsert Using INSERT ON CONFLICT statement
  • How to Generate a Random Number in A Range
  • Using PostgreSQL ADD COLUMN to Add One or More Columns To a Table
  • PostgreSQL Character Types: CHAR, VARCHAR, and TEXT
  • Using PostgreSQL SERIAL To Create Auto-increment Column
  • PostgreSQL Boolean Data Type with Practical Examples
  • Understanding PostgreSQL Timestamp Data Types

More Tutorials

  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Functions
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2016 by PostgreSQL Tutorial Website. All Rights Reserved.