> ## 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 VIEW

> The `ALTER VIEW` command modifies the metadata of a view. To use this command, you must own the view.

## Syntax

```sql theme={null}
ALTER VIEW view_name
    alter_option;
```

`alter_option` depends on the operation you want to perform on the view. For all supported clauses, see the sections below.

## Clause

### `OWNER TO`

```sql theme={null}
ALTER VIEW view_name
    OWNER TO new_user;
```

| Parameter or clause | Description                                   |
| :------------------ | :-------------------------------------------- |
| **OWNER TO**        | This clause changes the owner of the view.    |
| *new\_user*         | The new owner you want to assign to the view. |

```sql theme={null}
-- Change the owner of the view named "view1" to user "user1"
ALTER VIEW view1 OWNER TO user1;
```

### `SET SCHEMA`

```sql theme={null}
ALTER VIEW view_name
    SET SCHEMA schema_name;
```

| Parameter or clause | Description                                             |
| :------------------ | :------------------------------------------------------ |
| **SET SCHEMA**      | This clause moves the view to a different schema.       |
| *schema\_name*      | The name of the schema to which the view will be moved. |

```sql theme={null}
-- Move the view named "test_view" to the schema named "test_schema"
ALTER VIEW test_view SET SCHEMA test_schema;
```

### `RENAME TO`

```sql theme={null}
ALTER VIEW view_name
    RENAME TO new_name;
```

| Parameter or clause | Description                               |
| :------------------ | :---------------------------------------- |
| **RENAME TO**       | This clause changes the name of the view. |
| *new\_name*         | The new name of the view.                 |

```sql theme={null}
-- Change the name of the view named "view1" to "view2"
ALTER VIEW view1 RENAME TO view2;
```

### `SWAP WITH`

```sql theme={null}
ALTER VIEW name
SWAP WITH target_name;
```

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

```sql theme={null}
-- Swap the names of the user_profiles view and the guest_profiles view.
ALTER VIEW user_profiles
SWAP WITH guest_profiles;
```
