

# DROP SCALEOUT TABLE

Use `DROP SCALEOUT TABLE` to remove a scaleout table from the routing layer of a database cluster group for Aurora.

## Description and syntax
<a name="databaseclustergroups-sql-drop-scaleout-table-syntax"></a>

Removes one scaleout table. Its member tables, rows, data mappings, collocations, and routing function stay.

```sql
DROP SCALEOUT TABLE {{table_name}};
```

## Parameters and options
<a name="databaseclustergroups-sql-drop-scaleout-table-parameters"></a>

The statement takes the following parameters and options.

{{table\_name}}  
The scaleout table, by the name that you created it with. One statement drops one scaleout table.

## Where it runs and required privileges
<a name="databaseclustergroups-sql-drop-scaleout-table-privileges"></a>

Run the statement at the routing endpoint, in a session that isn't pinned, outside a transaction. For the details, see [Where these statements run](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-where-statements-run).

The router user needs `dbclustergroup_metadata_admin` or `dbclustergroup_super_admin`. For all privileges for database cluster groups for Aurora, see [Privileges](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-privileges).

## Usage notes
<a name="databaseclustergroups-sql-drop-scaleout-table-usage"></a>

Keep the following in mind when you use the statement.
+ Drop the tables that use this one with `OF` first.
+ The statement removes only the scaleout table. To remove the routing function, data mappings, and member tables, follow the reverse of the [order of creation](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-order-of-creation): drop the routing function, delete the data mappings, and drop the member tables on their member clusters.
+ Save the table's `SHOW CREATE SCALEOUT TABLE` output first. You can't read back a dropped scaleout table.

## Examples
<a name="databaseclustergroups-sql-drop-scaleout-table-examples"></a>

The following example drops a child table, then its parent, then their routing function.

```sql
DROP SCALEOUT TABLE items;
DROP SCALEOUT TABLE orders;
DROP SCALEOUT ROUTING FUNCTION orders_mod_fn;
```

## Errors
<a name="databaseclustergroups-sql-drop-scaleout-table-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 | 
| --- | --- | 
| [1235](databaseclustergroups-errors-scaleout.md#databaseclustergroups-data-mapping-and-scaleout-ddl-errors) failed to remove table(s) <name>: cannot drop scaleout table '<name>': other scaleout tables inherit its routing function | Other tables were created OF this one. Drop or switch them first. | 
| [64001](databaseclustergroups-errors-scaleout.md#databaseclustergroups-data-mapping-and-scaleout-ddl-errors) Scaleout table '<name>' doesn't exist | No scaleout table has that name. Include IF EXISTS to succeed when the table doesn't exist. | 
| [1064](databaseclustergroups-errors-routing.md#databaseclustergroups-routing-and-statement-errors) | Syntax error: a form outside the grammar, such as a list of tables in one statement. | 
| [1227](databaseclustergroups-errors-connection.md) Access denied; you need the '<PRIVILEGE>' privilege for this operation | The router user lacks the privilege for database cluster groups for Aurora. | 

If you include `IF EXISTS` and no scaleout table has the name, the statement succeeds and returns no error or warning.

## Related statements
<a name="databaseclustergroups-sql-drop-scaleout-table-related"></a>

For more information, see the following:
+ [CREATE SCALEOUT TABLE](databaseclustergroups-sql-create-scaleout-table.md)
+ [DROP SCALEOUT ROUTING FUNCTION](databaseclustergroups-sql-drop-scaleout-routing-function.md)
+ [DELETE FROM dbclustergroup\_sys.data\_mappings](databaseclustergroups-sql-delete-data-mappings.md)
+ [SHOW CREATE SCALEOUT TABLE](databaseclustergroups-sql-show-create-scaleout-table.md)