Chapter 38. The Information Schema

Table of Contents

38.1. The Schema
38.2. Data Types
38.3. information_schema_catalog_name
38.4. administrable_role_​authorizations
38.5. applicable_roles
38.6. attributes
38.7. character_sets
38.8. check_constraint_routine_usage
38.9. check_constraints
38.10. collations
38.11. collation_character_set_​applicability
38.12. column_column_usage
38.13. column_domain_usage
38.14. column_options
38.15. column_privileges
38.16. column_udt_usage
38.17. columns
38.18. constraint_column_usage
38.19. constraint_table_usage
38.20. data_type_privileges
38.21. domain_constraints
38.22. domain_udt_usage
38.23. domains
38.24. element_types
38.25. enabled_roles
38.26. foreign_data_wrapper_options
38.27. foreign_data_wrappers
38.28. foreign_server_options
38.29. foreign_servers
38.30. foreign_table_options
38.31. foreign_tables
38.32. key_column_usage
38.33. parameters
38.34. referential_constraints
38.35. role_column_grants
38.36. role_routine_grants
38.37. role_table_grants
38.38. role_udt_grants
38.39. role_usage_grants
38.40. routine_column_usage
38.41. routine_privileges
38.42. routine_routine_usage
38.43. routine_sequence_usage
38.44. routine_table_usage
38.45. routines
38.46. schemata
38.47. sequences
38.48. sql_features
38.49. sql_implementation_info
38.50. sql_parts
38.51. sql_sizing
38.52. table_constraints
38.53. table_privileges
38.54. tables
38.55. transforms
38.56. triggered_update_columns
38.57. triggers
38.58. udt_privileges
38.59. usage_privileges
38.60. user_defined_types
38.61. user_mapping_options
38.62. user_mappings
38.63. view_column_usage
38.64. view_routine_usage
38.65. view_table_usage
38.66. 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.