PostgreSQL has A ALTER SCHEMA statement that is used to modify the definition of an existing schema.
Syntax:
ALTER SCHEMA schema_name
ACTION xyz;
Let’s analyze the above syntax:
- First, specify the name of the schema that you want to modify after the ALTER SCHEMA keywords.
- Second, specify the operation you need to perform.
- ACTION can be any valid PostgreSQL operation like RENAME, DROP etc.
Let’s take some examples of using the ALTER SCHEMA statement to get a better understanding.
Example 1:
This example uses the ALTER SCHEMA statement to rename the schema geeksforgeeks
to gfg
:
ALTER SCHEMA geeksforgeeks
RENAME TO gfg;
To verify the change use the below statement:
SELECT
*
FROM
pg_catalog.pg_namespace
ORDER BY
nspname;
Output:

Example 2:
The following example uses the ALTER SCHEMA statement to change the owner of the schema gfg
to from Raju
to postgres
:
ALTER SCHEMA gfg
OWNER TO postgres;
To verify the change use the below statement:
SELECT
*
FROM
pg_catalog.pg_namespace
ORDER BY
nspname;
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
28 Aug, 2020
Like Article
Save Article