• Data Warehouse Service

dws
  1. Help Center
  2. Data Warehouse Service
  3. Developer Guide
  4. SQL Reference
  5. SQL Syntax
  6. ALTER SCHEMA

ALTER SCHEMA

Function

ALTER SCHEMA changes the attributes of a schema.

Only the owner of an index can execute this command. By default, a system administrator also can execute this command.

Precautions

None

Syntax

  • Rename a schema.
    ALTER SCHEMA schema_name 
        RENAME TO new_name;
  • Changes the owner of a schema.
    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

-- 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