PostgreSQL query to list all table names?

jobi88 picture jobi88 · Feb 6, 2013 · Viewed 237.4k times · Source

Is there any query available to list all tables in my Postgres DB.

I tried out one query like:

SELECT table_name FROM information_schema.tables
                      WHERE table_schema='public' 

But this query returns views also.

How can i get only table names only, not views?

Answer

vyegorov picture vyegorov · Feb 6, 2013

What bout this query (based on the description from manual)?

SELECT table_name
  FROM information_schema.tables
 WHERE table_schema='public'
   AND table_type='BASE TABLE';