

# member\_cluster\_mappings

The `dbclustergroup_sys.member_cluster_mappings` system table has one row for each member cluster of a database cluster group for Aurora.

## Purpose
<a name="databaseclustergroups-sysviews-member-cluster-mappings-purpose"></a>

Use this table to translate between the two names of a member cluster. Data mappings, session pins, and moves name a member cluster by its alias, which exists only at the routing layer. The Amazon RDS console, the AWS CLI, and Amazon CloudWatch show its DB cluster identifier. Aliases follow the group's member clusters, so you don't invent one. Keep the following points in mind when you use an alias:
+ Read the alias from this table and copy it into each data mapping. Don't derive it from a DB cluster identifier or from the position of a cluster in the group.
+ An `UPDATE` of this table renames one alias, with `WHERE member_cluster_alias = '<old>'`. Existing data mappings keep pointing at the same member cluster and show the new name on the next `SELECT`, so a rename needs no mapping change. A `dbclustergroup_metadata_admin` user can also swap the DB clusters of two aliases with one `CASE` `UPDATE` on `db_cluster_identifier`. The swap re-routes their collocations without copying data, and it changes two rows.
+ A new member cluster appears in this table when it can route. Until its alias is listed, the routing layer refuses a data mapping that names it and writes no row. The error is 64004 (SQLSTATE `42000`) on Aurora MySQL. For the error text, see [Routing and data mapping error codes](databaseclustergroups-errors-routing.md#databaseclustergroups-routing-and-statement-errors). For the procedure, see [Adding and removing member clusters](databaseclustergroups-member-clusters.md).

The table accepts `SELECT` and `UPDATE`. It rejects `INSERT` and `DELETE`, because the aliases come from the group's member clusters, and you add and remove member clusters through the group. An alias whose member cluster isn't in the group shows `NULL` in `db_cluster_identifier`.

When you remove a member cluster from the group, its row stays in `member_cluster_mappings` with `db_cluster_identifier` set to `NULL`. The collocation groups and data mappings under the alias stay too, but have no member cluster to route to. To remove the alias with its collocation groups and data mappings, run `CALL dbclustergroup_sys.cleanup_member_cluster_alias('<alias>')` with autocommit on, outside a transaction. This needs the `dbclustergroup_metadata_admin` privilege. The call reports 1 affected row when it removes the alias, and 0 when the alias doesn't exist. It fails with error `1235` while the member cluster is still in the group. It also fails with error `1235` while a scaleout table or a routing function uses a collocation group under the alias. If you add the member cluster back before cleaning up, its alias is listed again.

## Columns and example queries
<a name="databaseclustergroups-sysviews-member-cluster-mappings-columns"></a>

The table has the following columns.


| Column | Type | Description | 
| --- | --- | --- | 
| member\_cluster\_alias | VARCHAR | The name of the member cluster at the routing layer. Use it in data mappings, in a session pin, and in ALTER DBCLUSTERGROUP MOVE … FROM and TO. You also see it in data\_mappings, the process list, and move\_info. | 
| db\_cluster\_identifier | VARCHAR | The DB cluster identifier that the alias points at. You change it only with an UPDATE that sets it with a CASE on member\_cluster\_alias, which exchanges the member clusters of two aliases. Use it with the AWS CLI and the Amazon RDS console to find the endpoint, instances, and metrics of the cluster. | 

**Where to query it**

Query the table at the routing endpoint, in query routing mode, in an unpinned session. For the connection, see [Where to query the system tables](databaseclustergroups-system-views.md#databaseclustergroups-sysviews-where).

Reading the table needs `dbclustergroup_metadata_read_only` or `dbclustergroup_metadata_admin`. Renaming an alias needs `dbclustergroup_metadata_admin`. `dbclustergroup_super_admin` covers both.

A `WHERE` clause takes one equality with a quoted literal. The only exception is the swap of DB clusters, which uses `WHERE member_cluster_alias IN ('<a>','<b>')` and changes two rows. An `UPDATE` that renames an alias must match one row. For the query shapes that work, see [Filters the system tables accept](databaseclustergroups-system-views.md#databaseclustergroups-sysviews-filters).

**Example queries**

The following query lists every member cluster, with its alias and DB cluster identifier.

```sql
SELECT member_cluster_alias, db_cluster_identifier FROM dbclustergroup_sys.member_cluster_mappings;
```

The following query returns the alias of a cluster that you added.

```sql
SELECT member_cluster_alias
  FROM dbclustergroup_sys.member_cluster_mappings
 WHERE db_cluster_identifier = 'app-member-c';
```

The following statement renames the alias `member-b` to `orders-member`.

```sql
UPDATE dbclustergroup_sys.member_cluster_mappings
   SET member_cluster_alias = 'orders-member'
 WHERE member_cluster_alias = 'member-b';
```

## Related topics
<a name="databaseclustergroups-sysviews-member-cluster-mappings-related"></a>

For more information, see the following topics:
+ [data\_mappings](databaseclustergroups-sysviews-data-mappings.md), which names each object's member cluster by alias
+ [Adding and removing member clusters](databaseclustergroups-member-clusters.md)
+ [router\_cluster\_pin](databaseclustergroups-router-session-variables.md#databaseclustergroups-sysviews-router-cluster-pin), the session variable that pins a session to a member cluster alias
+ [Names, IDs, and consistency](databaseclustergroups-system-views.md#databaseclustergroups-sysviews-ids)