Reputation: 11
I want to extract the names of the tables I have.
The code below returns me tables AND views.
SELECT quote_ident(table_name) as tab_name
FROM information_schema.tables
WHERE table_schema='public'
Question
How can I obtain just the table names and exclude the views?
Upvotes: 1
Views: 234
Reputation: 5482
From the documentation (emphasis mine):
The view
tables
contains all tables and views defined in the current database.
You can use the table_type
column to exclude views:
SELECT quote_ident(table_name) as tab_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_type != 'VIEW'
Upvotes: 2