> ## Documentation Index
> Fetch the complete documentation index at: https://docs.risingwave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ALTER SWAP

The `ALTER ... SWAP` command enables the exchange of names between two database objects, such as tables, materialized views, views, sources, sinks, or subscriptions. It simplifies the process of renaming two objects by allowing them to be swapped in a single operation.

<Note>
  The objects being swapped must be of the same type; otherwise, an error will be returned.
</Note>

## Syntax

```sql theme={null}
ALTER [ TABLE | MATERIALIZED VIEW | VIEW | SOURCE | SINK | SUBSCRIPTION ] name
SWAP WITH target_name;
```

## Parameter

| Parameter      | Description                                                   |
| :------------- | :------------------------------------------------------------ |
| *name*         | The current name of the database object to swap.              |
| *target\_name* | The target name of the database object you want to swap with. |

## Example

```sql theme={null}
ALTER MATERIALIZED VIEW historical_sales
SWAP WITH current_sales;
```
