

# DROP SCALEOUT ROUTING FUNCTION

Use `DROP SCALEOUT ROUTING FUNCTION` to remove a routing function from a database cluster group for Aurora.

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

Removes a routing function that no scaleout table uses. Data mappings, member tables, and rows stay as they are.

```sql
DROP SCALEOUT ROUTING FUNCTION {{function_name}};
```

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

The statement takes the following parameter.

{{function\_name}}  
The routing function to remove.

## Where it runs and required privileges
<a name="databaseclustergroups-sql-drop-scaleout-routing-function-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-routing-function-usage"></a>

Keep the following in mind when you use the statement.
+ You can't drop a function that a scaleout table uses, directly or through `USING ROUTING FUNCTION OF`. Drop or switch those tables first.
+ Save the function's `SHOW CREATE SCALEOUT ROUTING FUNCTION` output first. You can't read back a dropped function.
+ To remove a scaleout table and its function, follow the reverse of the [order of creation](databaseclustergroups-sql-reference.md#databaseclustergroups-sql-order-of-creation).

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

The following example drops `tenant_rf` after `orders` has switched to `tenant_rf_v2`.

```sql
DROP SCALEOUT ROUTING FUNCTION tenant_rf;
```

## Errors
<a name="databaseclustergroups-sql-drop-scaleout-routing-function-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 | 
| --- | --- | 
| [64042](databaseclustergroups-errors-scaleout.md#databaseclustergroups-data-mapping-and-scaleout-ddl-errors) Cannot drop routing function '<function\_name>' referenced by scaleout tables (42000) | A scaleout table still uses the function. | 
| [1064](databaseclustergroups-errors-routing.md#databaseclustergroups-routing-and-statement-errors) | Syntax error: a form outside the grammar. | 
| [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. | 

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

For more information, see the following:
+ [CREATE SCALEOUT ROUTING FUNCTION](databaseclustergroups-sql-create-scaleout-routing-function.md)
+ [SHOW CREATE SCALEOUT ROUTING FUNCTION](databaseclustergroups-sql-show-create-scaleout-routing-function.md)
+ [ALTER SCALEOUT TABLE](databaseclustergroups-sql-alter-scaleout-table.md)
+ [DROP SCALEOUT TABLE](databaseclustergroups-sql-drop-scaleout-table.md)