Show TOC

Background documentationCREATE SCHEMA Statement (create_schema_statement) Locate this document in the navigation structure

 

The CREATE SCHEMA statement (create_schema_statement) defines a schema.

Structure

Syntax Syntax

  1. <create_schema_statement> ::=
      CREATE SCHEMA <schema_name_clause> [<schema_element>...]
    
    <schema_name_clause> ::=
      <schema_name>
    | <schema_name> AUTHORIZATION <schema_authorization_identifier>
    
    <schema_authorization_identifier> ::=
      <identifier>
    
    <schema_element>  ::=
      <create_table_statement>
    | <create_view_statement>
    | <create_dbproc_statement>
    | <create_function_statement>
    | <create_sequence_statement>
End of the code.
Examples

SQL Tutorial, Schemas

Explanation

The current database user must be a database administrator.

The specified schema name (schema_name) must differ from the names of all existing schemas, database users, and roles. Using the CREATE SCHEMA statement you can create one of the following database objects in the schema (schema_elements): table, view table, database procedure, database function, sequence.

CREATE SCHEMA <schema_name>

A schema with the name schema_name is created. The current user (a database administrator) becomes the owner of this schema.

CREATE SCHEMA <schema_name> AUTHORIZATION <schema_authorization_identifier>

A schema with the name schema_name is created. The user specified by schema_authorization_identifier must exist and be a database administrator. This database administrator becomes the owner of the schema. The owner has the CREATEIN and DROPIN privileges for the generated schema and can therefore at any time add database objects to the schema or delete objects.

More Information

Privileges: Overview