From: | Adam Witney <awitney(at)sgul(dot)ac(dot)uk> |
---|---|
To: | Joao Miguel Ferreira <jmf(at)estg(dot)ipvc(dot)pt>, pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: how to list all tables in a database |
Date: | 2006-01-09 12:44:45 |
Message-ID: | BFE80B3D.5545D%awitney@sgul.ac.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 9/1/06 5:37 pm, "Joao Miguel Ferreira" <jmf(at)estg(dot)ipvc(dot)pt> wrote:
> Hello all,
>
> this is my first question... I'm really new to PG.
>
> How do I get a list of all tables in a database ?
>
> Is there an SQL command for this ?
If you are using psql then simply \dt
Or the SQL query that is performed by \dt is
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN
'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type",
u.usename as "Owner"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
Cheers
Adam
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Davis | 2006-01-09 12:47:11 | Re: how to list all tables in a database |
Previous Message | Charley Tiggs | 2006-01-08 13:18:33 | Re: primary key on lower(varchar) |