I have a postgresql script which selects all information about tables and views for specific database. I'm trying to add a additional column which will display comment associated with a table or a view. But I'm getting an error SQL state: 42P01, ERROR: relation "xxx" does not exist.
select tbl.*, (select obj_description(tbl.table_name::regclass::oid, 'pg_class')) as DESCRIPTION
from INFORMATION_SCHEMA.TABLES tbl
where tbl.table_schema <> 'pg_catalog' and tbl.table_schema <> 'information_schema'
order by tbl.table_schema, tbl.table_name
Unfortunately I have no idea what I'm doing wrong.
obj_description((tbl.table_schema || '.' || tbl.table_name)::regclass- use fully qualified names, including the schema name.selectclause so it could be:select tbl.*, obj_description(format('%I.%I',tbl.table_schema, tbl.table_name)::regclass, 'pg_class') as DESCRIPTION from ...Good luck.