Home:ALL Converter>PostgreSQL query for table column comments?

PostgreSQL query for table column comments?

Ask Time:2017-04-14T06:02:02         Author:Don

Json Formatter

I have migrated a MySQL database to PostgreSQL & replaced the query

SHOW FULL COLUMNS FROM schema_name.table_name;

with a Postgres equivalent,

SELECT * FROM information_schema.columns WHERE table_schema = 'schema_name' and table_name = 'table_name';

which returns the columns along with their properties however the 'Comment' property that was returned in the MySQL query is not returned in the PostgreSQL query.

Is there a way to query for the comments associated with each column_name?

Author:Don,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43402419/postgresql-query-for-table-column-comments
Dan :

How about this:\n\nselect col_description((table_schema||'.'||table_name)::regclass::oid, ordinal_position) as column_comment\n, * from information_schema.columns \nWHERE table_schema = 'schema_name' \nand table_name = 'table_name';\n",
2017-04-13T22:19:26
yy