---
title: "System catalog classes"
description: "Reference of the CoraDB system catalog classes (_db_class, _db_attribute, _db_index, _db_auth, ...) with their columns and example queries."
url: "https://www.coradb.ai/manual/sql/catalog_classes.html"
markdown_url: "https://www.coradb.ai/manual/markdown/sql/catalog_classes.md"
product: "CoraDB"
version: "1.0"
keywords: "coradb system catalog classes, _db_class, _db_attribute, _db_index, _db_partition, db_user, db_trigger, dual, data type codes"
---

# System catalog classes

The system catalog classes store the schema of a database: tables, columns, indexes, permissions, partitions, triggers and stored procedures. Their names mostly start with an underscore (`_db_class`, `_db_attribute`, …). CoraDB updates them automatically when DDL statements run.

The catalog classes are owned by **DBA** and only **DBA** can read them; even **DBA** cannot change them (see [Catalog authorization](https://www.coradb.ai/manual/sql/catalog.html#catalog-authorization)). Other users read the schema through the [system catalog views](https://www.coradb.ai/manual/sql/catalog_views.html), which show the same information in readable form and only for the tables the user may access.

Catalog classes refer to each other through object references: `_db_attribute.class_of`, for example, is the `_db_class` row of the table that the column belongs to. A path expression such as `class_of.class_name` follows such a reference, and `TABLE(collection)` turns a collection column such as `domains` into rows.

## \_db_class

One row for each table, view and system class. Indexed on `class_name`.

| Column | Type | Description |
|---|---|---|
| class_of | OBJECT | The internal class object. |
| class_name | VARCHAR(255) | Table name, in lowercase. |
| class_type | INTEGER | 0 table, 1 view, 3 graph topology, 4 vertex table, 5 edge table. |
| is_system_class | INTEGER | Flags: bit value 1 is set for a system class and bit value 8 for a table created with **REUSE_OID**. |
| owner | db_user | Owner. |
| inst_attr_count | INTEGER | Number of instance columns. |
| class_attr_count | INTEGER | Number of class attributes. |
| shared_attr_count | INTEGER | Number of shared attributes. |
| inst_meth_count | INTEGER | Number of instance methods. |
| class_meth_count | INTEGER | Number of class methods. |
| collation_id | INTEGER | Default collation ID of the table (see [\_db_collation](https://www.coradb.ai/manual/sql/catalog_classes.html#_db_collation)). |
| tde_algorithm | INTEGER | Encryption algorithm: 0 none, 1 AES, 2 ARIA. |
| sub_classes | SEQUENCE OF \_db_class | Direct subclasses (including the partitions of a partitioned table). |
| super_classes | SEQUENCE OF \_db_class | Direct superclasses. |
| inst_attrs | SEQUENCE OF \_db_attribute | Instance columns. |
| class_attrs | SEQUENCE OF \_db_attribute | Class attributes. |
| shared_attrs | SEQUENCE OF \_db_attribute | Shared attributes. |
| inst_meths | SEQUENCE OF \_db_method | Instance methods. |
| class_meths | SEQUENCE OF \_db_method | Class methods. |
| meth_files | SEQUENCE OF \_db_meth_file | Files that contain the method functions. |
| query_specs | SEQUENCE OF \_db_query_spec | Query of a view. |
| indexes | SEQUENCE OF \_db_index | Indexes of the table. |
| comment | VARCHAR(2048) | Table comment. |
| partition | SEQUENCE OF \_db_partition | Partitioning information. |

User-defined relational tables of the e-commerce database (no system flag, class type 0); the value 8 marks them as **REUSE_OID** tables:

```sql
SELECT class_name, class_type, inst_attr_count, is_system_class
FROM _db_class
WHERE MOD(is_system_class, 2) = 0 AND class_type = 0
ORDER BY class_name;
```

| class_name | class_type | inst_attr_count | is_system_class |
|---|---|---|---|
| countries | 0 | 2 | 8 |
| order_items | 0 | 4 | 8 |
| orders | 0 | 6 | 8 |

## \_db_attribute

One row for each column. Indexed on (`class_of`, `attr_name`, `attr_type`).

| Column | Type | Description |
|---|---|---|
| class_of | \_db_class | Table the column belongs to. |
| attr_name | VARCHAR(255) | Column name, in lowercase. |
| attr_type | INTEGER | 0 instance column, 1 class attribute, 2 shared attribute. |
| from_class_of | \_db_class | For an inherited column, the superclass that defines it; otherwise **NULL**. |
| from_attr_name | VARCHAR(255) | For an inherited column renamed to resolve a name conflict, its name in the superclass; otherwise **NULL**. |
| def_order | INTEGER | Position of the column in the table, from 0. An inherited column keeps its position in the superclass. |
| data_type | INTEGER | Data type code; see [Data type codes](https://www.coradb.ai/manual/sql/catalog_classes.html#data-type-codes). |
| default_value | VARCHAR(255) | Default value as a string, or **NULL** if there is none. |
| domains | SEQUENCE OF \_db_domain | Detailed type information. |
| is_nullable | INTEGER | 0 if the column has a **NOT NULL** constraint, 1 otherwise. |
| comment | VARCHAR(1024) | Column comment. |

### Data type codes

The codes used in `data_type` columns, as listed by [\_db_data_type](https://www.coradb.ai/manual/sql/catalog_classes.html#_db_data_type):

| Code | Type | Code | Type |
|---|---|---|---|
| 1 | INTEGER | 23 | BIT |
| 2 | FLOAT | 24 | VARBIT (BIT VARYING) |
| 3 | DOUBLE | 25 | CHAR |
| 4 | STRING (VARCHAR) | 26 | NCHAR |
| 5 | OBJECT | 27 | VARNCHAR |
| 6 | SET | 31 | BIGINT |
| 7 | MULTISET | 32 | DATETIME |
| 8 | SEQUENCE (LIST) | 33 | BLOB |
| 9 | ELO | 34 | CLOB |
| 10 | TIME | 35 | ENUM |
| 11 | TIMESTAMP | 36 | TIMESTAMPTZ |
| 12 | DATE | 37 | TIMESTAMPLTZ |
| 13 | MONETARY | 38 | DATETIMETZ |
| 18 | SHORT (SMALLINT) | 39 | DATETIMELTZ |
| 22 | NUMERIC | 40 | JSON |

The columns of `orders` with their type names:

```sql
SELECT a.attr_name, t.type_name, a.is_nullable
FROM _db_attribute a JOIN _db_data_type t ON a.data_type = t.type_id
WHERE a.class_of.class_name = 'orders'
ORDER BY a.def_order;
```

| attr_name | type_name | is_nullable |
|---|---|---|
| id | INTEGER | 0 |
| customer_id | INTEGER | 0 |
| shipped_date | DATE | 1 |
| shipping_cost | NUMERIC | 0 |
| ship_address | STRING | 0 |
| order_date | DATE | 0 |

## \_db_domain

Detailed type information of a column, method argument or collection element. Indexed on `object_of`.

| Column | Type | Description |
|---|---|---|
| object_of | OBJECT | The column, argument or domain this row describes. |
| data_type | INTEGER | Data type code; see [Data type codes](https://www.coradb.ai/manual/sql/catalog_classes.html#data-type-codes). |
| prec | INTEGER | Precision, or 0 if none. |
| scale | INTEGER | Scale, or 0 if none. |
| class_of | \_db_class | For an object type, the referenced table; otherwise **NULL**. |
| code_set | INTEGER | For a character type, the charset ID (see [\_db_charset](https://www.coradb.ai/manual/sql/catalog_classes.html#_db_charset)); otherwise 0. |
| collation_id | INTEGER | Collation ID of a character type. |
| enumeration | SEQUENCE OF STRING | Values of an **ENUM** type. |
| set_domains | SEQUENCE OF \_db_domain | For a collection type, the element types; otherwise **NULL**. |
| json_schema | STRING | JSON schema of a **JSON** column that has one. |

`TABLE(domains)` lists the domain of each column of `orders`. The `ship_address` column is a `VARCHAR(128)` in charset 5 (utf8) with collation 1 (utf8_bin):

```sql
SELECT a.attr_name, d.data_type, d.prec, d.code_set, d.collation_id
FROM _db_attribute a, TABLE(a.domains) AS t(d)
WHERE a.class_of.class_name = 'orders'
ORDER BY a.def_order;
```

| attr_name | data_type | prec | code_set | collation_id |
|---|---|---|---|---|
| id | 1 | 10 | 0 | 0 |
| customer_id | 1 | 10 | 0 | 0 |
| shipped_date | 12 | 10 | 0 | 0 |
| shipping_cost | 22 | 10 | 0 | 0 |
| ship_address | 4 | 128 | 5 | 1 |
| order_date | 12 | 10 | 0 | 0 |

## \_db_charset

| Column | Type | Description |
|---|---|---|
| charset_id | INTEGER | Charset ID. |
| charset_name | VARCHAR(32) | Charset name. |
| default_collation | INTEGER | ID of the default collation. |
| char_size | INTEGER | Maximum size of one character in bytes. |

The charsets are:

| charset_id | charset_name | char_size |
|---|---|---|
| 2 | binary | 1 |
| 3 | iso88591 | 1 |
| 4 | euckr | 3 |
| 5 | utf8 | 4 |

## \_db_collation

| Column | Type | Description |
|---|---|---|
| coll_id | INTEGER | Collation ID. |
| coll_name | VARCHAR(32) | Collation name. |
| charset_id | INTEGER | Charset ID. |
| built_in | INTEGER | 1 for a collation built into CoraDB, 0 for a collation from a locale library. |
| expansions | INTEGER | 1 if the collation uses expansions, 0 otherwise. |
| contractions | INTEGER | Number of contractions. |
| uca_strength | INTEGER | UCA strength code of a locale collation; 0 (not applicable) for built-in collations. |
| checksum | VARCHAR(32) | Checksum of the collation data of a locale collation. |

See [DB_COLLATION](https://www.coradb.ai/manual/sql/catalog_views.html#db_collation) for the list of collations and [Charset & collation rules](https://www.coradb.ai/manual/sql/i18n_collation.html) for their use.

## \_db_method

Methods of tables, mainly those of the system classes `db_user`, `db_authorization` and `db_root`. Indexed on (`class_of`, `meth_name`).

| Column | Type | Description |
|---|---|---|
| class_of | \_db_class | Table the method belongs to. |
| meth_name | VARCHAR(255) | Method name. |
| meth_type | INTEGER | 0 instance method, 1 class method. |
| from_class_of | \_db_class | For an inherited method, the superclass that defines it; otherwise **NULL**. |
| from_meth_name | VARCHAR(255) | For an inherited method renamed to resolve a name conflict, its name in the superclass; otherwise **NULL**. |
| signatures | SEQUENCE OF \_db_meth_sig | The C function called by the method. |

The class methods of `db_user`:

```sql
SELECT class_of.class_name AS class_name, meth_name
FROM _db_method
WHERE meth_type = 1 AND class_of.class_name = 'db_user'
ORDER BY meth_name;
```

| class_name | meth_name |
|---|---|
| db_user | add_user |
| db_user | drop_user |
| db_user | find_user |
| db_user | login |

## \_db_meth_sig

The function behind a method. Indexed on `meth_of`.

| Column | Type | Description |
|---|---|---|
| meth_of | \_db_method | The method. |
| func_name | VARCHAR(255) | Name of the C function. |
| arg_count | INTEGER | Number of input arguments. |
| return_value | SEQUENCE OF \_db_meth_arg | Return value. |
| arguments | SEQUENCE OF \_db_meth_arg | Input arguments. |

## \_db_meth_arg

Method arguments. Indexed on `meth_sig_of`.

| Column | Type | Description |
|---|---|---|
| meth_sig_of | \_db_meth_sig | The function the argument belongs to. |
| data_type | INTEGER | Data type code; see [Data type codes](https://www.coradb.ai/manual/sql/catalog_classes.html#data-type-codes). |
| index_of | INTEGER | Position: 0 for the return value, 1 and up for input arguments. |
| domains | SEQUENCE OF \_db_domain | Detailed type information. |

## \_db_meth_file

Files that contain method functions. Indexed on `class_of`.

| Column | Type | Description |
|---|---|---|
| class_of | \_db_class | Table the file belongs to. |
| from_class_of | \_db_class | For inherited file information, the superclass that defines it; otherwise **NULL**. |
| path_name | VARCHAR(255) | Path of the file. |

## \_db_query_spec

The query of a view. Indexed on `class_of`.

| Column | Type | Description |
|---|---|---|
| class_of | \_db_class | The view. |
| spec | VARCHAR(1073741823) | The view's query, as stored by CoraDB. |

## \_db_index

One row for each index, including those created for primary keys, unique and foreign key constraints. Indexed on `class_of`.

| Column | Type | Description |
|---|---|---|
| class_of | \_db_class | Table the index belongs to. |
| index_name | VARCHAR(255) | Index name. |
| is_unique | INTEGER | 1 for a unique index or primary key, 0 otherwise. |
| key_count | INTEGER | Number of key columns. |
| key_attrs | SEQUENCE OF \_db_index_key | Key columns. |
| is_reverse | INTEGER | 1 for a reverse index, 0 otherwise. |
| is_shared | INTEGER | 1 if the index is shared by a table hierarchy (primary keys, unique and shared indexes), 0 otherwise. |
| is_primary_key | INTEGER | 1 for a primary key, 0 otherwise. |
| is_foreign_key | INTEGER | 1 for a foreign key, 0 otherwise. |
| filter_expression | VARCHAR(255) | Condition of a filtered index. |
| have_function | INTEGER | 1 for a function-based index, 0 otherwise. |
| comment | VARCHAR(1024) | Index comment. |
| status | INTEGER | 0 no index, 1 normal, 2 invisible, 3 being built online. |

## \_db_index_key

One row for each key column of an index. Indexed on `index_of`.

| Column | Type | Description |
|---|---|---|
| index_of | \_db_index | The index. |
| key_attr_name | VARCHAR(255) | Name of the key column. |
| key_order | INTEGER | Position of the column in the key, from 0. |
| asc_desc | INTEGER | 1 for a descending key column, 0 otherwise. |
| key_prefix_length | INTEGER | Prefix length used as key, or -1 if the whole value is used. |
| func | VARCHAR(255) | Expression of a function-based index key. |

The key columns of the indexes of `order_items` that have more than one key column:

```sql
SELECT i.index_name, k.key_attr_name, k.key_order
FROM _db_index i, _db_index_key k
WHERE k.index_of = i AND i.class_of.class_name = 'order_items' AND i.key_count >= 2
ORDER BY k.key_order;
```

| index_name | key_attr_name | key_order |
|---|---|---|
| pk_order_items_order_id_product_id | order_id | 0 |
| pk_order_items_order_id_product_id | product_id | 1 |

## \_db_auth

Permissions granted on tables. Indexed on `grantee`.

| Column | Type | Description |
|---|---|---|
| grantor | db_user | User who granted the permission. |
| grantee | db_user | User or group who received it. |
| class_of | \_db_class | The table. |
| auth_type | VARCHAR(7) | **SELECT**, **INSERT**, **UPDATE**, **DELETE**, **ALTER**, **INDEX** or **EXECUTE**. |
| is_grantable | INTEGER | 1 if the grantee may grant the permission to others (**WITH GRANT OPTION**), 0 otherwise. |

```sql
SELECT grantor.name AS grantor, grantee.name AS grantee, auth_type
FROM _db_auth
WHERE class_of.class_name = 'db_trig';
```

| grantor | grantee | auth_type |
|---|---|---|
| DBA | PUBLIC | SELECT |

## \_db_data_type

The data types and their codes, as listed in [Data type codes](https://www.coradb.ai/manual/sql/catalog_classes.html#data-type-codes).

| Column | Type | Description |
|---|---|---|
| type_id | INTEGER | Data type code. |
| type_name | VARCHAR(16) | Data type name. |

## \_db_partition

Partitioning information: one row for the partitioned table itself and one for each partition. Indexed on (`class_of`, `pname`).

| Column | Type | Description |
|---|---|---|
| class_of | \_db_class | The partitioned table (its own row) or the partition. |
| pname | VARCHAR(255) | Partition name; **NULL** in the partitioned table's row. |
| ptype | INTEGER | 0 hash, 1 range, 2 list. |
| pexpr | VARCHAR(2048) | In the partitioned table's row, the partitioning expression (stored as a query); **NULL** for partitions. |
| pvalues | SEQUENCE | For a range partition, the lower and upper bound (**NULL** for **MINVALUE** and **MAXVALUE**); for a list partition, its values. |
| comment | VARCHAR(1024) | Partition comment. |

A hash-partitioned and a list-partitioned table:

```sql
CREATE TABLE cust_h (id INT, name VARCHAR(40)) PARTITION BY HASH (id) PARTITIONS 3;
CREATE TABLE city_l (id INT, region VARCHAR(10))
PARTITION BY LIST (region) (PARTITION p_north VALUES IN ('north', 'east'), PARTITION p_south VALUES IN ('south'));

SELECT class_of.class_name AS class_name, pname, ptype, pexpr, pvalues
FROM _db_partition
WHERE class_of.class_name LIKE 'cust_h%' OR class_of.class_name LIKE 'city_l%'
ORDER BY 1, 2;
```

| class_name | pname | ptype | pexpr | pvalues |
|---|---|---|---|---|
| city_l | NULL | 2 | SELECT [region] FROM [city_l] | NULL |
| city_l\_\_p\_\_p_north | p_north | 2 | NULL | {'north', 'east'} |
| city_l\_\_p\_\_p_south | p_south | 2 | NULL | {'south'} |
| cust_h | NULL | 0 | SELECT [id] FROM [cust_h] | NULL |
| cust_h\_\_p\_\_p0 | p0 | 0 | NULL | {NULL} |
| cust_h\_\_p\_\_p1 | p1 | 0 | NULL | {NULL} |
| cust_h\_\_p\_\_p2 | p2 | 0 | NULL | {NULL} |

[DB_PARTITION](https://www.coradb.ai/manual/sql/catalog_views.html#db_partition) shows the same information in readable form.

## \_db_stored_procedure

Java stored functions and procedures. Unique index on `sp_name`.

| Column | Type | Description |
|---|---|---|
| sp_name | VARCHAR(255) | Name. |
| sp_type | INTEGER | 1 procedure, 2 function. |
| return_type | INTEGER | Data type code of the return value; 0 for none (procedures), 28 for a cursor. |
| arg_count | INTEGER | Number of arguments. |
| args | SEQUENCE OF \_db_stored_procedure_args | Arguments. |
| lang | INTEGER | Implementation language (1 = Java). |
| target | VARCHAR(4096) | The Java method that is called. |
| owner | db_user | Owner. |
| comment | VARCHAR(1024) | Comment. |

## \_db_stored_procedure_args

Arguments of stored functions and procedures. Indexed on `sp_name`.

| Column | Type | Description |
|---|---|---|
| sp_name | VARCHAR(255) | Name of the stored function or procedure. |
| index_of | INTEGER | Position of the argument, from 0. |
| arg_name | VARCHAR(255) | Argument name. |
| data_type | INTEGER | Data type code. |
| mode | INTEGER | 1 IN, 2 OUT, 3 INOUT. |
| comment | VARCHAR(1024) | Argument comment. |

## db_user

Users and groups. Unique index on `name`.

| Column | Type | Description |
|---|---|---|
| name | VARCHAR(1073741823) | User name, in uppercase. |
| id | INTEGER | User ID. |
| password | db_password | Encrypted password; not shown to users. |
| direct_groups | SET OF db_user | Groups the user belongs to directly. |
| groups | SET OF db_user | Groups the user belongs to, directly or indirectly. |
| authorization | db_authorization | The user's permissions. |
| triggers | SEQUENCE OF OBJECT | The user's triggers. |
| comment | VARCHAR(1024) | User comment. |

The methods of `db_user` (`add_user`, `drop_user`, `find_user`, `login`, `set_password`, `add_member`, `drop_member`, `print_authorizations`, …) are used internally by statements such as [CREATE USER](https://www.coradb.ai/manual/sql/authorization.html); use those statements rather than calling the methods.

## db_authorization

| Column | Type | Description |
|---|---|---|
| owner | db_user | The user. |
| grants | SEQUENCE OF OBJECT | The permissions the user has received: for each, the table, the grantor and the permission type. |

## db_trigger

One row for each trigger.

| Column | Type | Description |
|---|---|---|
| owner | db_user | Owner. |
| name | VARCHAR(1073741823) | Trigger name. |
| status | INTEGER | 1 inactive, 2 active (default). |
| priority | DOUBLE | Priority; default 0. |
| event | INTEGER | 0 **UPDATE**, 1 **STATEMENT UPDATE**, 2 **DELETE**, 3 **STATEMENT DELETE**, 4 **INSERT**, 5 **STATEMENT INSERT**, 8 **COMMIT**, 9 **ROLLBACK**. |
| target_class | OBJECT | The target table. |
| target_attribute | VARCHAR(1073741823) | The target column, or **NULL** if none is given. |
| target_class_attribute | INTEGER | 0 if the target column is an instance column, 1 if it is a class attribute. |
| condition_type | INTEGER | 1 if the trigger has a condition, **NULL** otherwise. |
| condition | VARCHAR(1073741823) | The **IF** condition. |
| condition_time | INTEGER | When the condition is evaluated: 1 **BEFORE**, 2 **AFTER**, 3 **DEFERRED**; **NULL** without a condition. |
| action_type | INTEGER | 1 **INSERT**, **UPDATE** or **DELETE** statement, 2 **REJECT**, 3 **INVALIDATE TRANSACTION**, 4 **PRINT**. |
| action_definition | VARCHAR(1073741823) | The action statement. |
| action_time | INTEGER | When the action runs: 1 **BEFORE**, 2 **AFTER**, 3 **DEFERRED**. |
| comment | VARCHAR(1024) | Trigger comment. |

See [Triggers](https://www.coradb.ai/manual/sql/trigger.html) and the [DB_TRIG](https://www.coradb.ai/manual/sql/catalog_views.html#db_trig) view.

## dual

A table with one row and one column, used to evaluate expressions that do not need a table. A **SELECT** without a **FROM** clause reads `dual` implicitly.

| Column | Type | Description |
|---|---|---|
| dummy | VARCHAR(1) | Contains `'X'`. |

```sql
SELECT * FROM dual;
```

| dummy |
|---|
| X |
