Chapter 31. The Information Schema

Table of Contents
31.1. The Schema
31.2. Data Types
31.3. information_schema_catalog_name
31.4. applicable_roles
31.5. check_constraints
31.6. column_domain_usage
31.7. column_privileges
31.8. column_udt_usage
31.9. columns
31.10. constraint_column_usage
31.11. constraint_table_usage
31.12. data_type_privileges
31.13. domain_constraints
31.14. domain_udt_usage
31.15. domains
31.16. element_types
31.17. enabled_roles
31.18. key_column_usage
31.19. parameters
31.20. referential_constraints
31.21. role_column_grants
31.22. role_routine_grants
31.23. role_table_grants
31.24. role_usage_grants
31.25. routine_privileges
31.26. routines
31.27. schemata
31.28. sql_features
31.29. sql_implementation_info
31.30. sql_languages
31.31. sql_packages
31.32. sql_sizing
31.33. sql_sizing_profiles
31.34. table_constraints
31.35. table_privileges
31.36. tables
31.37. triggers
31.38. usage_privileges
31.39. view_column_usage
31.40. view_table_usage

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 modelled 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.

31.1. The Schema

The information schema itself is a schema named information_schema. This schema automatically exists in all databases. The owner of this schema is the initial database user in the cluster, and that user naturally has all the privileges on this schema, including the ability to drop it (but the space savings achieved by that are minuscule).

By default, the information schema is not in the schema search path, so you need to access all objects in it through qualified names. Since the names of some of the objects in the information schema are generic names that might occur in user applications, you should be careful if you want to put the information schema in the path.