There are several databases. How to get a list of database tables and fields of these tables in Postgres?
Answer 1, Authority 100%
select table_name, column_name
from information_schema.columns.
Where Table_schema = 'Public'
Answer 2, Authority 50%
select datname from pg_database where datistemplate = false;
Select table_name from information_schema.Tables Where Table_schema = 'Public' Order by Table_Name;
Select Table_Name, column_name from information_schema.columns Where Table_schema = 'Public'
Update
- PK Key
SELECT
PG_ATTRIBUTE.ATTNAME,
Format_Type (pg_attribute.atttypid, pg_attribute.atttypmod)
From pg_index, pg_class, pg_attribute, pg_namespace
Whater
PG_CLASS.OID = 'Tablename' :: RegClass and
indrelid = pg_class.oid and
NSPName = 'Public' and
pg_class.relnamespace = pg_namespace.oid and
pg_attribute.attrelid = pg_class.oid and
pg_attribute.attnum = any (PG_INDEX.INDKEY)
And indisprimary