deeejay

psql - View column names and date types for a table or view

Feb 13th, 2015
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Query for specific view
  2. ===
  3. SELECT column_name, data_type
  4. FROM   information_schema.columns
  5. WHERE  table_name = 'vw_some_view_name'
  6. ORDER  BY ordinal_position;
  7.  
  8. Query all tables and views within a database and/or schema
  9. ===
  10. SELECT table_catalog, table_schema, table_name, column_name, data_type, character_maximum_length
  11. FROM   information_schema.columns
  12. WHERE  table_name NOT LIKE 'pg_%'
  13. AND domain_schema IS NULL
  14. AND table_schema = 'allied'
  15. ORDER BY table_name, ordinal_position;
Advertisement
Add Comment
Please, Sign In to add comment