ALTER ... SWAP
ALTER ... SWAP atomically renames two items.
|The identifier of the item you want to swap.
|The target identifier of the item you want to swap with.
Swapping two items is useful for a blue/green deployment
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:
- Ownership of both objects being swapped.