Re: Retrieving a list of tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



select * from pg_tables where name not like 'pg_%';

\dS gives you a list of system tables.

with psql -E 

\dt gives you 

SELECT c.relname as "Name", 'table'::text as "Type", u.usename as "Owner"
FROM pg_class c, pg_user u
WHERE c.relowner = u.usesysid AND c.relkind = 'r'
  AND not exists (select 1 from pg_views where viewname = c.relname)
  AND c.relname !~ '^pg_'
UNION
SELECT c.relname as "Name", 'table'::text as "Type", NULL as "Owner"
FROM pg_class c
WHERE c.relkind = 'r'
  AND not exists (select 1 from pg_views where viewname = c.relname)
  AND not exists (select 1 from pg_user where usesysid = c.relowner)
  AND c.relname !~ '^pg_'

ORDER BY "Name"

-----Original Message-----
From: David C. Brown [mailto:dbrown@xxxxxxxxxxxxxxxxxxx]
Sent: Tuesday, October 16, 2001 10:09 PM
To: pgsql-php@xxxxxxxxxxxxxx
Subject: [PHP] Retrieving a list of tables


Heyas,

    I need to be able to get a list of the tables from a postgresql from
php.  I'm
porting a php-mysql website over to postgresql.    I have a form that
populates
a <SELECT> statment with the tables in the db.

In Mysql I just used the sql query "SHOW TABLES;" postgresql doesn't
support that sql statment, and pg-php doesn't like me sending a "\d" as
a
query.

Anyone have any help, or ideas how I may be able to work around this?
or is there a query for pg-sql that I don't know about?

Any and all help would be great...  Thanx

Dave


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux