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.
PostgreSQL describe table is defined as check the structure of table, we can describe the structure of table by using \d and table name command in PostgreSQL. In PostgreSQL describe table statement is not present like MySQL instead of describe we have using \d table name and \d+ table name.
In pgAdmin 4, we are going to use the information_schema for describing the tables. Here, the information schema itself is a schema that is automatically present in all databases and called information_schema. And by default, it is not available in the schema search path.
Now reach "tables" in pgAdmin III window, right click on "tables" and click on "New Table". This will open a new window to create a New Table. Supply a name of your new table and then click on Columns.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With