

# SET scaleout\_tables\_preferred\_member

Aurora MySQL only. Names the member table that describes a scaleout table in this session of a database cluster group for Aurora. The variable answers `SHOW CREATE TABLE`, `SHOW COLUMNS`, `SHOW INDEX`, and `DESCRIBE` on a scaleout table, which drivers, ORMs, and schema tools depend on.

## Description
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-description"></a>

A scaleout table has no table of its own on a member cluster, so these statements answer from the member table that the session names. If the variable isn't set, or names a table that isn't a member of the scaleout table, the statement fails with error `1146`. When the variable names a member table, `SHOW CREATE TABLE` shows the member table's name in its `Table` column.

For how the routing layer holds the variable, see [scaleout\_tables\_preferred\_member](databaseclustergroups-router-session-variables.md#databaseclustergroups-sysviews-preferred-member).

## Syntax
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-syntax"></a>

```sql
SET [SESSION] scaleout_tables_preferred_member = '{{scaleout_table}}:{{db}}.{{member_table}}[,{{scaleout_table}}:{{db}}.{{member_table}} ...]';
```

## Parameters and options
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-parameters"></a>

The statement takes the following parameters.

{{scaleout\_table}}  
The scaleout table name alone, without its database.

{{db}}.{{member\_table}}  
One of its member tables, by the router database name and router table name that its data mapping gives it, not by its cluster name. To name member tables for several scaleout tables, separate the pairs with commas.

## Where it runs and required privileges
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-privileges"></a>

Run the statement at the routing endpoint, in a session that isn't pinned. In a pinned session, describe the member table by its cluster name instead. The statement needs no privilege for database cluster groups for Aurora, and the routing layer doesn't send it to a member cluster. For the full list of these privileges, see [Privileges](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-privileges).

## Usage notes
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-usage"></a>

The routing layer holds the variable for the session. Set it before the first metadata statement on a scaleout table.

In a new connection the variable is empty. Read it with `SELECT @@scaleout_tables_preferred_member` or `SHOW VARIABLES`; the routing layer answers both and never sends the variable to a member cluster. Set it to `''` to clear it. Set it in a `SET` statement of its own: a `SET` that also assigns another variable returns error 1235. When you set it, the routing layer checks only the format of the value and returns error 1231 for a malformed value. It doesn't check that the named tables exist, so a wrong name returns error 1146 on the next `SHOW` or `DESCRIBE`.

## Examples
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-examples"></a>

The following example reads the definition of `app.orders` from its member table `app.orders_m3`.

```sql
SET SESSION scaleout_tables_preferred_member = 'orders:app.orders_m3';
SHOW CREATE TABLE app.orders;
```

## Errors
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-errors"></a>

The statement can return the following errors. For all errors from the routing layer, see [Error codes for database cluster groups for Aurora](databaseclustergroups-error-reference.md).


| Aurora MySQL | Meaning | 
| --- | --- | 
| 1231 (42000) | Variable can't be set to this value: the value isn't a comma-separated list of scaleout\_table:member pairs, or it has more than 25,000 pairs. | 
| 1235 (42000) | The SET statement also assigns another variable. Set scaleout\_tables\_preferred\_member on its own. | 
| [1146](databaseclustergroups-errors-routing.md) (on the SHOW or DESCRIBE statement) | The variable isn't set, or names a table that isn't a member of the scaleout table. | 

## Related statements
<a name="databaseclustergroups-sql-set-scaleout-tables-preferred-member-related"></a>

For more information, see the following:
+ [SHOW CREATE SCALEOUT TABLE](databaseclustergroups-sql-show-create-scaleout-table.md)
+ [SET router\_cluster\_pin](databaseclustergroups-sql-set-router-cluster-pin.md)