CREATE SCHEMA

Syntax

CREATE SCHEMA schema_name [IN DATABASE database_name];

Description

A Schema is a logical grouping of relational objects such as Streams, Changelogs and Materialized Views. Schemas are grouped in a Database. A combination of databases and schemas enable users to organize their streams, Changelogs, and other Database objects in a hierarchical fashion in DeltaStream. Such hierarchies also are one of the bases for providing Role-based Access Control (RBAC) in DeltaStream the same way as other relational databases. CREATE SCHEMA enters a new Schema into the current Database. The Schema name must be distinct from the name of any existing Schema in the current Database.

Arguments

schema_name

Name of the Schema to create. For case-sensitive names, the name must be wrapped in double quotes, otherwise, the lowercased name will be used.

IN DATABASE database_name

Optionally, the Database the Schema should be created in. For case-sensitive names, the name must be wrapped in double quotes, otherwise, the lowercased name will be used.

Examples

Create a new Schema in default Database

The following creates a new Schema named newschema in the current Database demodb:

demodb.public/<no-store># CREATE SCHEMA newschema;
+------------+------------------+------------+------------------------------------------+
|  Type      |  Name            |  Command   |  Summary                                 |
+============+==================+============+==========================================+
| schema     | demodb.newschema | CREATE     | schema "demodb.newschema" was            |
|            |                  |            | successfully created                     |
+------------+------------------+------------+------------------------------------------+
demodb.public/<no-store># LIST SCHEMAS;
+------------+-------------+------------+-------------------------------+
|  Name      |  Is Default |  Owner     |  Created At                   |
+============+=============+============+===============================+
| public     | true        | sysadmin   | 2024-05-09 22:02:29 +0000 UTC |
+------------+-------------+------------+-------------------------------+
| newschema  | false       | sysadmin   | 2024-05-09 22:02:41 +0000 UTC |
+------------+-------------+------------+-------------------------------+

Create a new Schema in a specified Database

The following creates a new Schema named NewSchema in the specified Database otherdb:

demodb.public/<no-store># CREATE SCHEMA "NewSchema" IN DATABASE otherdb;
+------------+-------------------+------------+------------------------------------------+
|  Type      |  Name             |  Command   |  Summary                                 |
+============+===================+============+==========================================+
| schema     | otherdb.NewSchema | CREATE     | schema "otherdb.NewSchema" was           |
|            |                   |            | successfully created                     |
+------------+-------------------+------------+------------------------------------------+
demodb.public/<no-store># LIST SCHEMAS IN DATABASE otherdb;
+------------+-------------+------------+-------------------------------+
|  Name      |  Is Default |  Owner     |  Created At                   |
+============+=============+============+===============================+
| public     | true        | sysadmin   | 2024-05-09 21:56:57 +0000 UTC |
+------------+-------------+------------+-------------------------------+
| NewSchema  | false       | sysadmin   | 2024-05-09 22:03:45 +0000 UTC |
+------------+-------------+------------+-------------------------------+

Last updated