pg_class
The pg_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
The following columns are available for querying in pg_class:
| Column | Type | Description |
|---|---|---|
|
|
This column represents the table/index object ID (OID) that Redpanda SQL generates. |
|
|
This column represents the table/index name as specified by the user during creation |
|
|
This column represents the OID of the namespace the relation resides in |
|
|
Returns |
|
|
This column represents the type of relation: |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
|
|
Unused |
Examples
-
Create a table and define its schema:
CREATE TABLE customer_orders ( order_id INT, customer_id INT, order_date DATE, total_amount INT ); -
Create an index on the
customer_orderstable for thecustomer_idcolumn:CREATE INDEX idx_customer_id ON customer_orders (customer_id); -
Query the
pg_classcatalog to retrieve information about thecustomer_orderstable and the index you’ve just created:SELECT oid, relname, relkind, relhasindex, relnamespace FROM pg_class WHERE relname IN ('customer_orders', 'idx_customer_id'); -
The query returns information about the
customer_orderstable and the index:oid | relname | relkind | relhasindex | relnamespace ------+-----------------+---------+-------------+-------------- 1013 | idx_customer_id | i | f | 0 1012 | customer_orders | r | t | 0 (2 rows)