How can I list the columns in INFORMATION_SCHEMA.COLUMNS?
postgresql, sql
Solution
Tablename and schema name are stored in two columns:
SELECT column_name, data_type
FROM INFORMATION_SCHEMA.COLUMNS
where table_name = 'columns'
and table_schema = 'information_schema';
More details in the manual: http://www.postgresql.org/docs/current/static/infoschema-columns.html
Problem
Normally, if I want to list columns and types in a table called `foo` in the current database, I would use the following SQL statement. ``` SELECT column_name, data_type FROM INFORMATION_SCHEMA.COLUMNS where table_name = 'foo'; ``` However, I want to list the columns in the table `INFORMATION_SCHEMA.COLUMNS`, and the following statement returns zero results. ``` SELECT column_name, data_type FROM INFORMATION_SCHEMA.COLUMNS where table_name = 'INFORMATION_SCHEMA.COLUMNS'; ``` What is the correct way to list the columns in the table above, in `psql`?