3
System Catalog
A set of tables and views
describing all objects in a database cluster
Schemas
primary schema: pg_catalog
alternative representation: information_schema (SQL standard)
SQL access
view: SELECT
change: CREATE, ALTER, DROP
psql access
commands for convenient data visualization
The system catalog is a collection of tables and views that describe all
database objects. It is metadata for the contents of the cluster:
Starting from version 14 of PostgreSQL, primary keys and unique
constraints have been added for most system catalog tables.
You can access this metadata using regular SQL queries. SELECT
commands can give you a description of an object, and DDL (Data Definition
Language) commands let you add and modify objects.
All system catalog tables and views are located in the pg_catalog schema.
There is another schema, as defined by the SQL standard:
information_schema. It is more stable and portable than pg_catalog, but
does not reflect specific features of PostgreSQL.
Client programs can read the contents of the system catalog and display it to
the user in a convenient way. For example, GUI-based development and
management environments usually come with a hierarchical object
navigation tool.
The psql client also offers a number of convenient built-in commands
specifically designed for working with the system catalog. Most of these
commands start with \d (as in “describe”). For the full list of commands and
their descriptions, see:
We will look at the most commonly used ones in the demo.
The course materials also include the catalogs.pdf file that features a
diagram of the main system catalog tables and related psql commands.