/ Published in: SQL
Get table schema with columns via sql.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
SELECT ordinal_position, column_name, data_type, is_nullable, description.description AS comment FROM information_schema.columns COLUMNS LEFT JOIN pg_class class ON (COLUMNS.table_name = class.relname) LEFT JOIN pg_description description ON (class.oid = description.objoid) LEFT JOIN pg_attribute attrib ON (class.oid = attrib.attrelid AND COLUMNS.column_name = attrib.attname AND attrib.attnum = description.objsubid) WHERE TABLE_NAME='{$tableName}' GROUP BY ordinal_position, column_name, data_type, is_nullable, description.description