ALTER SCHEMA
Redefines a schema.
Syntax
ALTER SCHEMA <name> RENAME TO <new_name>
ALTER SCHEMA <name> OWNER TO { <new_owner> | CURRENT_USER | SESSION_USER }
Description
You can run ALTER SCHEMA
to redefine the schema that you own.
When you use ALTER SCHEMA
to rename a schema, you must be the schema owner and have the CREATE
privilege on the database to which the schema belongs.
When you use ALTER SCHEMA
to alter the owner of a schema, you must own the schema and have the direct or indirect membership in the new owning role. In addition, the new owning role must have the CREATE
privilege on the database to which the schema belongs.
Parameters
-
<name>
The name of the schema.
-
<new_name>
The new name of the schema. Dot not start with
pg_
. Schemas whose names start withpg_
are system-reserved schemas. -
<new_owner>
,CURRENT_USER
, orSESSION_USER
The new owner of the schema.
<new_owner>
: explicitly specifies the new owning role.CURRENT_USER
: alters the owner to the current user.SESSION_USER
: alters the owner to the current session user.
Examples
Rename schema basicinfo
to basic_info
:
ALTER SCHEMA basicinfo RENAME TO basic_info;
Alter the owner of scheme basic_info
to [email protected]
:
ALTER SCHEMA basic_info OWNER TO "[email protected]";
SQL standard compatibility
The SQL standard does not support ALTER SCHEMA
.