prom
prom copied to clipboard
Better way to list columns in Postgres
SELECT column_name FROM information_schema.columns where table_name = '<TABLE NAME>'
This seems way better than the horrible query I'm using right now
Search
- postgres 12.8 get fields of table
- https://stackoverflow.com/questions/25639088/show-table-structure-and-list-of-tables-in-postgresql
- https://www.postgresqltutorial.com/postgresql-administration/postgresql-describe-table/
- postgres get table schema with query
Looks like information_schema.columns doesn't give primary key information. I could combine the output of information_schema.columns with information_schema.table_constraints to make this work but I'm not sure it's worth it.
This is the postgres wiki solution on getting primary key