Chapter 36. The Information Schema

Table of Contents

36.1. The Schema
36.2. Data Types
36.3. information_schema_catalog_name
36.4. administrable_role_authorizations
36.5. applicable_roles
36.6. attributes
36.7. character_sets
36.8. check_constraint_routine_usage
36.9. check_constraints
36.10. collations
36.11. collation_character_set_applicability
36.12. column_column_usage
36.13. column_domain_usage
36.14. column_options
36.15. column_privileges
36.16. column_udt_usage
36.17. columns
36.18. constraint_column_usage
36.19. constraint_table_usage
36.20. data_type_privileges
36.21. domain_constraints
36.22. domain_udt_usage
36.23. domains
36.24. element_types
36.25. enabled_roles
36.26. foreign_data_wrapper_options
36.27. foreign_data_wrappers
36.28. foreign_server_options
36.29. foreign_servers
36.30. foreign_table_options
36.31. foreign_tables
36.32. key_column_usage
36.33. parameters
36.34. referential_constraints
36.35. role_column_grants
36.36. role_routine_grants
36.37. role_table_grants
36.38. role_udt_grants
36.39. role_usage_grants
36.40. routine_privileges
36.41. routines
36.42. schemata
36.43. sequences
36.44. sql_features
36.45. sql_implementation_info
36.46. sql_languages
36.47. sql_packages
36.48. sql_parts
36.49. sql_sizing
36.50. sql_sizing_profiles
36.51. table_constraints
36.52. table_privileges
36.53. tables
36.54. transforms
36.55. triggered_update_columns
36.56. triggers
36.57. udt_privileges
36.58. usage_privileges
36.59. user_defined_types
36.60. user_mapping_options
36.61. user_mappings
36.62. view_column_usage
36.63. view_routine_usage
36.64. view_table_usage
36.65. views

The information schema consists of a set of views that contain information about the objects defined in the current database. The information schema is defined in the SQL standard and can therefore be expected to be portable and remain stable — unlike the system catalogs, which are specific to PostgreSQL and are modeled after implementation concerns. The information schema views do not, however, contain information about PostgreSQL-specific features; to inquire about those you need to query the system catalogs or other PostgreSQL-specific views.

Note

When querying the database for constraint information, it is possible for a standard-compliant query that expects to return one row to return several. This is because the SQL standard requires constraint names to be unique within a schema, but PostgreSQL does not enforce this restriction. PostgreSQL automatically-generated constraint names avoid duplicates in the same schema, but users can specify such duplicate names.

This problem can appear when querying information schema views such as check_constraint_routine_usage, check_constraints, domain_constraints, and referential_constraints. Some other views have similar issues but contain the table name to help distinguish duplicate rows, e.g., constraint_column_usage, constraint_table_usage, table_constraints.