There isn't a general purpose DESCRIBE or SHOW TABLES in Pg's sql syntax if you aren't using the command line psql tool. ( try \dt and \d tablename if you are).
You can peruse the source for psql (look at describe.c), or use the -E option to psql to dump it's internal SQL commands it uses for \dt and \d.
For the lazier folks, here's postgres running
\dt and \d on a table called fees, along with the
SQL commands that \d and \dt use behind the scenes
test=# \dt ********* QUERY ********* SELECT c.relname as "Name", 'table'::text as "Type", u.usename as "Own +er" FROM pg_class c, pg_user u WHERE c.relowner = u.usesysid AND c.relkind = 'r' 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_user where usesysid = c.relowner) AND c.relname !~ '^pg_' ORDER BY "Name" ************************* List of relations Name | Type | Owner -----------------+-------+---------- billing | table | postgres fees | table | postgres flgtatt | table | postgres <I truncated this here> test=# \d fees ********* QUERY ********* SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules FROM pg_class WHERE relname='fees' ************************* ********* QUERY ********* SELECT a.attname, format_type(a.atttypid, a.atttypmod), a.attnotnull, +a.atthasde f, a.attnum FROM pg_class c, pg_attribute a WHERE c.relname = 'fees' AND a.attnum > 0 AND a.attrelid = c.oid ORDER BY a.attnum ************************* ********* QUERY ********* SELECT c2.relname FROM pg_class c, pg_class c2, pg_index i WHERE c.relname = 'fees' AND c.oid = i.indrelid AND i.indexrelid = c2. +oid ORDER BY c2.relname ************************* Table "fees" Attribute | Type | Modifier -----------+-----------------------+---------- type | character varying(10) | not null amount | numeric(8,2) | effdate | date | Index: fees_pkey
In reply to Re: DBI - MySQL vs. PgSQL
by kschwab
in thread DBI - MySQL vs. PgSQL
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |