Monday 8 August 2011

Learning pg

SHOW TABLES is
SELECT table_schema, table_name FROM information_schema.tables ;

SHOW DATABASES is
SELECT table_schema, COUNT(*) AS num_tables FROM information_schema.tables
GROUP BY table_schema;


use /? to find out how to do it properly.

1 comment:

Kill Face said...

Rather:

SHOW DATABASES is:

SELECT datname FROM pg_database;


and SHOW TABLES (in a database) is:

SELECT
tablename
FROM
pg_tables
WHERE
schemaname = 'public'
;