Equivalent of "describe table" in PgAdmin3

user3112568 picture user3112568 · Jan 29, 2014 · Viewed 52.8k times · Source

Question asked and answered:

As many of us know, PostgreSQL does not support describe table or describe view. As one might find from google, PostgreSQL uses \d+ instead.

However, if one accesses PostgreSQL using PgAdmin (I am actually using PgAdmin3) then \d+ does not work. What does one do instead?

I thought about this question when playing with the query tool in PgAdmin3. I had a "well, duh!" moment when I thought to look at the home window of PgAdmin3, and at the tree on the left side of that window. Under

<servername>
-> <databasename>
-> Schemas
-> <schemaname>
-> Tables

was a list of my tables, and clicking on the table name showed me text very much like what \d+ would have showed me.

So for the benefit of anyone else who did not discover this right away, here is an answer.

Answer

Gareth Flowers picture Gareth Flowers · Jan 29, 2014

PostgreSQL also supports the standard SQL information schema to retrieve details of objects in the database.

i.e. to get column information you can query the information_schema.columns view:

SELECT *
FROM information_schema.columns
WHERE table_name = '<YourTableName>';

Be sure to use single quotations, double quotes won't work

Check here for PostgreSQL specific details on the information schema.