ALTER SCHEMA
Function
ALTER SCHEMA changes the attributes of a schema.
Precautions
Only the owner of an index or a system administrator can run this statement.
Syntax
- Rename a schema.
1 2
ALTER SCHEMA schema_name RENAME TO new_name;
- Changes the owner of a schema.
1 2
ALTER SCHEMA schema_name OWNER TO new_owner;
Parameter Description
- schema_name
Indicates the name of the current schema.
Value range: An existing schema name.
- RENAME TO new_name
Renames a schema.
new_name: new name of the schema
Value range: A string. It must comply with the naming convention.
- OWNER TO new_owner
Changes the owner of a schema. To do this as a non-administrator, you must be a direct or indirect member of the new owning role, and that role must have CREATE permission in the database.
new_owner: new owner of a schema
Value range: An existing user name/role.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | -- Create the ds schema:
CREATE SCHEMA ds;
-- Rename the ds schema to ds_new:
ALTER SCHEMA ds RENAME TO ds_new;
-- Create user jack:
CREATE USER jack PASSWORD 'Bigdata123@';
-- Change the owner of ds_new to jack:
ALTER SCHEMA ds_new OWNER TO jack;
-- Delete user jack and the ds_new schema:
DROP SCHEMA ds_new;
DROP USER jack;
|
Helpful Links
Last Article: ALTER ROW LEVEL SECURITY POLICY
Next Article: ALTER SEQUENCE
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.