Overview
Thepg_class stores information about tables and indexes in the database. It contains exactly one row per table (or index) created in the database. It mimics the pg_class PostgreSQL system catalog.
Columns
This table is designed for compatibility with tools that require PostgreSQL system tables, so it mostly has dummy data. Please note that not all columns in
pg_class are applicable to every type of relation.pg_class:
| Column | Type | Description |
|---|---|---|
oid | int | This column represents the table/index object ID (OID) generated by oxla |
relname | text | This column represents the table/index name as specified by the user during creation |
relnamespace | int | This column represents the OID of the namespace the relation resides in |
relhasindex | bool | Returns true if the table has any indexes |
relkind | text | This column represents the type of relation: r for tables and i for indexes |
reltype | int | Unused |
reloftype | int | Unused |
relowner | int | Unused |
relam | int | Unused |
relfilenode | int | Unused |
reltablespace | int | Unused |
relpages | int | Unused |
reltuples | float | Unused |
relallvisible | int | Unused |
reltoastrelid | int | Unused |
relisshared | bool | Unused |
relpersistence | text | Unused |
relnatts | int | Unused |
relchecks | int | Unused |
relhasrules | bool | Unused |
relhastriggers | bool | Unused |
relhassubclass | bool | Unused |
relrowsecurity | bool | Unused |
relforcerowsecurity | bool | Unused |
relispopulated | bool | Unused |
relreplident | text | Unused |
relispartition | bool | Unused |
relrewrite | int | Unused |
relfrozenxid | int | Unused |
relacl | text | Unused |
reloptions | text | Unused |
relminmxid | text | Unused |
relpartbound | text | Unused |
Example
- Create a table and define its schema:
- Create an index on the
customer_orderstable for thecustomer_idcolumn:
- Query the
pg_classcatalog to retrieve information about thecustomer_orderstable and the index you’ve just created:
- The query will return information about the
customer_orderstable and the index: