CREATE SCHEMA (U-SQL)

Summary

This statement creates a new schema with the specified name in the current database context.

Syntax

Create_Schema_Statement :=                                                                               
    'CREATE' 'SCHEMA' ['IF' 'NOT' 'EXISTS'] Schema_Name.
Schema_Name := Quoted_or_Unquoted_Identifier.

Remarks

  • Schema_Name
    Specifies the name of the schema in form of a quoted or unquoted U-SQL identifier. If a schema of the given name already exists inside the current database context or the user has no permissions to create a schema, an error is raised.

  • IF NOT EXISTS
    If the optional IF NOT EXISTS is specified, then the statement creates the schema if it does not already exist, or succeeds without changes if the schema already exists and the user has permission to at least enumerate all existing schemas.

Examples

  • The examples can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
  • The scripts can be executed locally. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.

The following script shows how a user creates a schema called My Schema. Note that because of the space in the name, the identifier has to be quoted:

CREATE SCHEMA [My Schema];

If the user wants to create a schema in another database than the current database context, then the database context has to be changed explicitly. In the following example, a new database TestReferenceDB gets created that contains a new schema called NewSchema in addition to the automatically created dbo schema:

CREATE DATABASE TestReferenceDB;  
USE DATABASE TestReferenceDB;  
CREATE SCHEMA NewSchema;

See Also