doc/user/content/sql/alter-schema.md
Use ALTER SCHEMA to:
{{< tabs >}} {{< tab "Swap with" >}}
To swap the name of a schema with that of another schema:
{{% include-syntax file="examples/alter_schema" example="syntax-swap-with" %}}
{{< /tab >}} {{< tab "Rename schema" >}}
To rename a schema:
{{% include-syntax file="examples/alter_schema" example="syntax-rename" %}}
{{< /tab >}} {{< tab "Change owner to" >}}
To change the owner of a schema:
{{% include-syntax file="examples/alter_schema" example="syntax-change-owner" %}}
{{< /tab >}}
{{< /tabs >}}
Swapping two schemas is useful for a blue/green deployment. The following swaps
the names of the blue and green schemas.
CREATE SCHEMA blue;
CREATE TABLE blue.numbers (n int);
CREATE SCHEMA green;
CREATE TABLE green.tags (tag text);
ALTER SCHEMA blue SWAP WITH green;
-- The schema which was previously named 'green' is now named 'blue'.
SELECT * FROM blue.tags;
The privileges required to execute this statement are:
{{% include-headless "/headless/sql-command-privileges/alter-schema" %}}