Help Center > > Developer Guide> SQL Reference> SQL Syntax> ALTER SCHEMA

ALTER SCHEMA

Updated at: Mar 13, 2020 GMT+08:00

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

CREATE SCHEMA, DROP SCHEMA

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel