

# EXPLAIN ALTER DBCLUSTERGROUP MOVE COLLOCATION

Previews a move of one collocation between member clusters of a database cluster group for Aurora before you start it.

## Description
<a name="databaseclustergroups-sql-explain-move-collocation-description"></a>

The preview validates the statement and reports what the move would do, without starting a job. It runs every precheck that the routing layer runs and moves nothing. It reports precheck errors and warnings in its result rather than failing. It reports the following:
+ Validation errors, such as a missing table or an incompatible configuration
+ The count of database and table mappings that the move will update
+ The collocation that the move resolved, on the `Collocation` line
+ Whether the move turns on the binary log on your behalf

A wrong object name or a missing dependency shows here while the source is still the only copy.

## Syntax
<a name="databaseclustergroups-sql-explain-move-collocation-syntax"></a>

```sql
EXPLAIN ALTER DBCLUSTERGROUP MOVE COLLOCATION {{collocation_group}}
  FROM {{source_member_cluster_alias}} TO {{target_member_cluster_alias}}
  [{{move_option}} [, {{move_option}}]]

{{move_option}}:
    MANUAL_CUTOVER = { 0 | 1 }
  | PRESERVE_GRANTS_FOR = ('{{user}}' [, ...])
```

## Parameters and options
<a name="databaseclustergroups-sql-explain-move-collocation-parameters"></a>

The parameters and options are the same as for [ALTER DBCLUSTERGROUP MOVE COLLOCATION](databaseclustergroups-sql-move-collocation.md#databaseclustergroups-sql-move-collocation-parameters).

## Where it runs and required privileges
<a name="databaseclustergroups-sql-explain-move-collocation-privileges"></a>

Run the statement at the routing endpoint, outside a transaction, in a session that isn't pinned. Inside a transaction, the statement returns error 1179. The router user needs `dbclustergroup_move_admin` or `dbclustergroup_super_admin`. For the privileges for database cluster groups for Aurora, see [Privileges](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-privileges).

## Usage notes
<a name="databaseclustergroups-sql-explain-move-collocation-usage"></a>

Keep the following in mind when you use the statement.
+ Read back the number of table and database mappings the preview reports within the collocation to confirm that it matches your expectation.
+ A move runs a lighter set of checks before it creates the job, and the job runs its own prechecks on the member clusters after that, so a move that passes the preview can still fail on the job. That failure appears in the job's `move_info` row.
+ Preview a move of a default collocation, whose name is the member cluster alias, before you start it. That collocation holds every object on the member cluster that you mapped without a collocation, so read the number of table and database mappings that the preview reports.
+ Check that the statement starts with `EXPLAIN`. Without it, the same text starts a move.

`EXPLAIN ALTER DBCLUSTERGROUP MOVE COLLOCATION` returns one row in one column. The column holds a report in the tree format of MySQL `EXPLAIN`:

```
mysql> EXPLAIN ALTER DBCLUSTERGROUP MOVE COLLOCATION `{{collocation_group}}` FROM `{{source_member_cluster_alias}}` TO `{{target_member_cluster_alias}}`\G
*************************** 1. row ***************************
EXPLAIN ALTER DBCLUSTERGROUP MOVE COLLOCATION: Status: Success (1 warning)
Collocation: {{collocation_group}}
Cutover Type: AUTOMATIC
Database data mapping updates: 0
Table data mapping updates: 1
Warnings:
  Binary logging is disabled on the source '{{source_member_cluster_alias}}'; the data-movement job will enable it dynamically for the duration of the move, and will check the binlog filter lists then. Long-running transactions on the source can delay the start of the move.
1 row in set (0.03 sec)
```

`Status` reads `Success`, `Success ({{n}} warnings)`, or `ERROR ({{n}} errors, {{n}} warnings)`. `Collocation` names the collocation that the move resolved. `Cutover Type` reads `AUTOMATIC` or `MANUAL`. The two update lines count the database-level and table-level data mappings of the collocation that the move updates. The `Errors:` and `Warnings:` lists appear only when they have entries. If the binary log is off on the source member cluster, a warning tells you that the job turns it on: `Binary logging is disabled on the source '{{source_member_cluster_alias}}'; the data-movement job will enable it dynamically for the duration of the move, and will check the binlog filter lists then. Long-running transactions on the source can delay the start of the move.`

## Examples
<a name="databaseclustergroups-sql-explain-move-collocation-examples"></a>

The following example previews a move of `cg_06` from `cluster_b` to `cluster_c` that waits for a manual cutover.

```sql
EXPLAIN ALTER DBCLUSTERGROUP MOVE COLLOCATION cg_06 FROM cluster_b TO cluster_c MANUAL_CUTOVER = 1;
```

## Errors
<a name="databaseclustergroups-sql-explain-move-collocation-errors"></a>

The statement can return the following errors, and the syntax errors of [ALTER DBCLUSTERGROUP MOVE COLLOCATION](databaseclustergroups-sql-move-collocation.md#databaseclustergroups-sql-move-collocation-errors). For all data movement errors, see [Data movement errors](databaseclustergroups-errors-movement.md).


| Aurora MySQL | Meaning | 
| --- | --- | 
| [1227](databaseclustergroups-errors-movement.md) | The router user lacks dbclustergroup\_move\_admin. | 
| [1179](databaseclustergroups-errors-movement.md) | The statement ran inside a transaction. Run it outside a transaction. | 

## Related statements
<a name="databaseclustergroups-sql-explain-move-collocation-related"></a>

For more information, see the following:
+ [ALTER DBCLUSTERGROUP MOVE COLLOCATION](databaseclustergroups-sql-move-collocation.md)
+ [Reading move status](databaseclustergroups-sql-move-info.md)