Search Postgresql Archives

Re: listing relations

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

 



On Thu, 11 Jun 2009, Brandon Metcalf wrote:

Is there a "\" command to show all tables in the current search path?

SELECT
  nspname,relname,relkind
FROM
  pg_class c,
  pg_namespace n
WHERE
  c.relnamespace = n.oid AND
  relkind='r' AND
  nspname !~ '^pg_toast' AND
  nspname = ANY(current_schemas(false))
ORDER BY
  nspname,relname;

Change "false" to "true" if you want to include the stuff in pg_catalog too. Remove the filter on relkind if you want to see things besides just tables. There's a bunch of other system info functions you might find useful documented at http://www.postgresql.org/docs/8.3/static/functions-info.html as well.

(The pg_toast filter is probably redundant here, I try to keep that in all these pg_class/pg_namespace join examples because it's handy for more normal queries)

--
* Greg Smith gsmith@xxxxxxxxxxxxx http://www.gregsmith.com Baltimore, MD

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux