

# System tables for database cluster groups for Aurora

The routing layer of a database cluster group for Aurora keeps its metadata in system tables in reserved schemas. It answers queries on these tables from its own state, not from any member cluster. Query them at the routing endpoint, in an unpinned session, to see the member clusters, the data mappings, the sessions at the routing endpoint, the router users, and the data movement jobs. Each table has its own topic with its columns and example queries. To change the data mappings, see [Data mapping statements](databaseclustergroups-sql-mappings.md). For session variables and the statements that the routing layer answers itself, see [Variables, character sets, and statements the routing layer answers](databaseclustergroups-session-variables.md).

**Topics**
+ [Where to query the system tables](#databaseclustergroups-sysviews-where)
+ [System tables](#databaseclustergroups-sysviews-tables)
+ [Visibility and privileges](#databaseclustergroups-sysviews-visibility)
+ [Filters the system tables accept](#databaseclustergroups-sysviews-filters)
+ [Tools that dump or introspect the system tables](#databaseclustergroups-sysviews-dumps)
+ [Names, IDs, and consistency](#databaseclustergroups-sysviews-ids)
+ [Related topics](#databaseclustergroups-sysviews-types)
+ [member\_cluster\_mappings](databaseclustergroups-sysviews-member-cluster-mappings.md)
+ [data\_mappings](databaseclustergroups-sysviews-data-mappings.md)
+ [Process list table: router\_processlist](databaseclustergroups-sysviews-router-processlist.md)
+ [router\_user\_definition](databaseclustergroups-sysviews-router-user-definition.md)
+ [move\_info](databaseclustergroups-sysviews-move-info.md)

## Where to query the system tables
<a name="databaseclustergroups-sysviews-where"></a>

The system tables exist only at the routing endpoint, not on any member cluster. In an unpinned session, the routing layer answers every statement on `dbclustergroup_sys` itself and never forwards it to a member cluster. The name `dbclustergroup_sys` is reserved in every letter case: a data mapping can't use it as a router name or a cluster name, and the routing layer rejects data definition statements on it.

A pinned session passes its statements through to its member cluster, so the system tables aren't visible there. The routing layer forwards a statement on `dbclustergroup_sys` in a pinned session to the member cluster, where it fails. For more information about pins, see [Session pinning](databaseclustergroups-sessions.md#databaseclustergroups-session-pinning).

A read of a system table reaches no member cluster, so it shows the declared mappings but doesn't test routing. To test routing, query a mapped table by its router name.

Run each write to `data_mappings` outside a transaction. You can read a system table inside a transaction.

Connect to the routing endpoint in query routing mode. The tables are in two reserved databases, `dbclustergroup_sys` and `dbclustergroup_data_movement`. A session with `autocommit = 0` counts as an open transaction.

## System tables
<a name="databaseclustergroups-sysviews-tables"></a>

The following table lists the system tables.


| Table | What it shows | Write access | 
| --- | --- | --- | 
| [dbclustergroup\_sys.member\_cluster\_mappings](databaseclustergroups-sysviews-member-cluster-mappings.md) | One row for each member cluster: its alias and the DB cluster it points at | SELECT and UPDATE. The routing layer rejects INSERT and DELETE, because an alias comes from the group's member clusters | 
| [dbclustergroup\_sys.data\_mappings](databaseclustergroups-sysviews-data-mappings.md) | One row for each data mapping: which database, schema, or table is on which member cluster, under which router name, in which collocation | Read and write. Writes to this table are how you change a mapping | 
| [Process list](databaseclustergroups-sysviews-router-processlist.md): dbclustergroup\_sys.router\_processlist | The sessions at the routing endpoint | Read only | 
| [dbclustergroup\_sys.router\_user\_definition](databaseclustergroups-sysviews-router-user-definition.md) | The router users and their privileges for database cluster groups for Aurora. It has no password column | Read only | 
| [dbclustergroup\_data\_movement.move\_info](databaseclustergroups-sysviews-move-info.md) | The state of one data movement job | Read only | 

No system table lists your scaleout tables or your routing functions. Keep your own copy of each `CREATE SCALEOUT ROUTING FUNCTION` and `CREATE SCALEOUT TABLE` statement. Read them with [SHOW SCALEOUT TABLES](databaseclustergroups-sql-show-scaleout.md), [SHOW CREATE SCALEOUT TABLE](databaseclustergroups-sql-show-create-scaleout-table.md), [SHOW SCALEOUT ROUTING FUNCTIONS](databaseclustergroups-sql-show-scaleout-routing-functions.md), and [SHOW CREATE SCALEOUT ROUTING FUNCTION](databaseclustergroups-sql-show-create-scaleout-routing-function.md). At the routing endpoint, `information_schema` lists a scaleout table under its own name, with the values of one member table. `TABLE_ROWS`, `DATA_LENGTH`, and the other statistics are that member table's values, not sums or averages.

Every column of `dbclustergroup_sys.member_cluster_mappings`, `dbclustergroup_sys.data_mappings`, and `dbclustergroup_data_movement.move_info` has the data type `VARCHAR`. In `dbclustergroup_sys.router_user_definition`, the `username`, `host`, `authentication_method`, `privileges`, and `grantable_privileges` columns are `VARCHAR`; `account_locked`, `password_expired`, and `require_ssl` are `TINYINT(1)`; and `password_expiry_interval_days` is `BIGINT`. In `dbclustergroup_sys.router_processlist`, the `id` and `time` columns are `BIGINT`, and the `user`, `host`, `db`, `command`, `state`, `info`, `member_cluster_alias`, and `pin_status` columns are `VARCHAR`.

## Visibility and privileges
<a name="databaseclustergroups-sysviews-visibility"></a>

Router users hold the privileges for database cluster groups for Aurora. The following privileges apply to the system tables:
+ A read of `member_cluster_mappings` or `data_mappings` needs `dbclustergroup_metadata_read_only`, `dbclustergroup_metadata_admin`, or `dbclustergroup_super_admin`.
+ A write to `data_mappings` needs `dbclustergroup_metadata_admin`.
+ The process list shows your own sessions to any router user. To see the sessions of other router users, you need `dbclustergroup_process_admin`. To end the sessions of other router users, you need `dbclustergroup_connection_admin`.
+ A read of `router_user_definition` needs `dbclustergroup_user_admin`.
+ `dbclustergroup_super_admin` carries every other privilege for database cluster groups for Aurora.

The other privileges for database cluster groups for Aurora are `dbclustergroup_move_admin`, for the data movement statements, and `dbclustergroup_metadata_read_only`, which reads `data_mappings`, `member_cluster_mappings`, and `move_info` without write access. For router users, member cluster users, and the full list of these privileges, see [Router users and routing layer privileges](databaseclustergroups-router-users.md).

A rename in `member_cluster_mappings` needs `dbclustergroup_metadata_admin`. A read of `move_info` needs `dbclustergroup_metadata_read_only` or `dbclustergroup_move_admin`.

## Filters the system tables accept
<a name="databaseclustergroups-sysviews-filters"></a>

The routing layer accepts a few query shapes on its system tables, with literal values only. Use a plain `SELECT`, and sort or filter further in your client. The routing layer rejects every other shape with error 1235 (SQLSTATE `42000`) on Aurora MySQL. For the error codes, see [Error codes for database cluster groups for Aurora](databaseclustergroups-error-reference.md).

The following table shows the query shapes on `data_mappings`. The same rules apply to the other system tables, except where a table's own topic says otherwise.


| Shape | Example | Result | 
| --- | --- | --- | 
| No WHERE | SELECT \* FROM dbclustergroup\_sys.data\_mappings | Accepted | 
| One equality, with a quoted literal | WHERE member\_cluster\_alias = 'member-b' | Accepted | 
| One tuple equality | WHERE (router\_db\_name, router\_table\_name) = ('app', 'orders') | Accepted | 
| COUNT(\*) as the only select item | SELECT COUNT(\*) FROM … WHERE member\_cluster\_alias = 'member-a' | Accepted | 
| Plain columns and column aliases in the select list | SELECT member\_cluster\_alias AS m FROM … | Accepted | 
| An expression, a subquery, or a variable as a value | WHERE member\_cluster\_alias = UPPER('member-b') | Rejected, with Only literal values are allowed. No expressions, subqueries, or variables. | 
| AND or OR | WHERE router\_db\_name = 'app' AND router\_table\_name = 'orders' | Rejected, with AND/OR are not supported in the WHERE clause on this table. Use the tuple form | 
| IN | WHERE member\_cluster\_alias IN ('member-a', 'member-b') | Rejected, with IN lists are not supported; use tuple equality | 
| \!=, <>, LIKE, IS NULL, or a range | WHERE router\_db\_name LIKE 'app%' | Rejected, with WHERE clause supports only column = 'value' or a tuple equality | 
| ORDER BY | … ORDER BY member\_cluster\_alias | Rejected, with ORDER BY is not supported on this table | 
| LIMIT n | … LIMIT 100 | Accepted | 
| LIMIT n OFFSET m | … LIMIT 100 OFFSET 200 | Accepted | 
| LIMIT m, n | … LIMIT 200, 100 | Accepted | 
| Another LIMIT or OFFSET form, such as OFFSET without LIMIT, or a non-integer bound | … OFFSET 10 | Rejected, with LIMIT and OFFSET on this table take the forms LIMIT n and LIMIT n OFFSET m (and LIMIT m, n on MySQL), with non-negative integer literals | 
| GROUP BY, HAVING, DISTINCT, or a locking read such as FOR UPDATE | … GROUP BY member\_cluster\_alias | Rejected, with a message that names the clause, for example GROUP BY and HAVING are not supported on this table | 
| Any other function or expression in the select list, or COUNT(\*) beside another item | SELECT COUNT(1) … | Rejected, with Functions and expressions are not supported in SELECT on this table (only COUNT(\*) as the sole select item is allowed) | 
| A join, a second table, or a subquery in FROM | … JOIN dbclustergroup\_sys.member\_cluster\_mappings … | Rejected, for example with JOINs are not supported on this table | 

## Tools that dump or introspect the system tables
<a name="databaseclustergroups-sysviews-dumps"></a>

The system tables exist only in the routing layer. No member cluster holds them, and they don't appear in `information_schema`. A read of `information_schema.TABLES` or `information_schema.COLUMNS` doesn't list them. A read filtered on `dbclustergroup_sys` or `dbclustergroup_data_movement` returns no rows. It doesn't fail. The routing layer reports every system table as `BASE TABLE`, including the tables that you can only read.

To inspect a system table, run `SHOW [FULL] TABLES`, `SHOW TABLE STATUS`, `SHOW [FULL] COLUMNS`, `DESCRIBE`, or `SHOW INDEX` at the routing endpoint, for example `SHOW COLUMNS FROM dbclustergroup_sys.data_mappings`. The routing layer answers these statements itself. It refuses `SHOW CREATE TABLE`, `SHOW CREATE DATABASE`, `SHOW TRIGGERS`, and `EXPLAIN` on a system table with error 1235.

A dump tool such as `mysqldump` can't dump the system tables, because the routing layer refuses the `SHOW CREATE TABLE`, `LOCK TABLES`, and `SELECT /*!40001 SQL_NO_CACHE */` statements that the tool sends for them. Leave `dbclustergroup_sys` and `dbclustergroup_data_movement` out of a dump, for example by naming only your own databases. To dump your data, dump each member cluster through its own endpoint. To keep a copy of the mappings, export `data_mappings` and `member_cluster_mappings` with a plain `SELECT` that has no modifiers. For the procedure, see [Exporting the mappings before and after a change](databaseclustergroups-changing-mappings.md#databaseclustergroups-export-mappings).

## Names, IDs, and consistency
<a name="databaseclustergroups-sysviews-ids"></a>

Keep these points in mind when you compare the system tables with other sources:
+ **Member cluster alias.** Data mappings, session pins, and moves name a member cluster by its alias. The alias exists only at the routing layer. The Amazon RDS console, the AWS CLI, and Amazon CloudWatch show the DB cluster identifier. Read the alias from [member\_cluster\_mappings](databaseclustergroups-sysviews-member-cluster-mappings.md), and don't derive it from a DB cluster identifier.
+ **Session ID.** The routing layer gives each client connection a global connection ID: a 32-bit positive integer that is unique across the group and names the connection. You see it in the process list, as `ID` in `router_processlist` on Aurora MySQL. On an Aurora MySQL member cluster, the connection attributes `_rds_router_connection_id` and `_rds_connection_source` carry the global connection ID and the source of the connection. To follow a session to its member cluster, see [Tracing a session or statement across the group](databaseclustergroups-trace-session.md).
+ **Names in catalogs.** A catalog read through the routing endpoint returns the names that the data mappings define. A pinned session or a direct connection returns cluster names. Route data statements through the routing endpoint, and run schema changes and catalog introspection through a pinned session or a direct connection. For more information, see [Statement compatibility](databaseclustergroups-compatibility.md).
+ **Declarations and data.** The system tables hold the placement that you declare. The routing layer doesn't compare these declarations with the objects or rows on the member clusters, and no statement reports a difference between them. Keeping the member clusters in step with your declarations stays under your control.

The DB cluster identifier appears in the system tables under the column name `db_cluster_identifier`, which is its public name.

## Related topics
<a name="databaseclustergroups-sysviews-types"></a>

Some routing layer state isn't in a system table. The following topics describe it, and how to follow a session to its member clusters:
+ Session variables: [Where the routing layer answers a variable or statement](databaseclustergroups-session-variables.md#databaseclustergroups-sysviews-session-variables)
+ Statements and catalog reads that the routing layer answers: [Statements the routing layer answers itself](databaseclustergroups-router-answers.md) and [SHOW, KILL, and catalog reads](databaseclustergroups-router-answers.md#databaseclustergroups-sysviews-catalog)
+ Following a session from the [process list](databaseclustergroups-sysviews-router-processlist.md) to its member cluster sessions and logs: [Tracing a session or statement across the group](databaseclustergroups-trace-session.md)