# CREATE SCHEMA

## Syntax <a href="#synopsis" id="synopsis"></a>

```sql
CREATE SCHEMA schema_name [IN DATABASE database_name];
```

## Description <a href="#description" id="description"></a>

A [schema](/overview/core-concepts/databases.md#_schema) is a logical grouping of relational objects such as [streams](/overview/core-concepts/databases.md#_stream), [changelogs](/overview/core-concepts/databases.md#_changelog) and [materialized views](/overview/core-concepts/databases.md#_materialized_view). Schemas are grouped in a [database](/overview/core-concepts/databases.md). A combination of databases and schemas enable you to organize your streams, changelogs, and other database objects in a hierarchical fashion in DeltaStream. Such hierarchies also serve as a basis for providing role-based access control (RBAC) in DeltaStream in 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. If the name is case-sensitive, you must wrap it in double quotes; otherwise, the system uses the lower case name.

#### IN DATABASE database\_name

Optionally, the database i which to create the schema. If the name is case-sensitive, you must wrap it in double quotes; otherwise, the system uses the lower case name.

## Examples

#### Create a new schema in default database

The following creates a new schema named `newschema` in the current database `demodb`:

```sh
demodb.public/<no-store># CREATE SCHEMA newschema;
+------------+----------------+------------+------------------------------------------+
|  Type      |  Name          |  Command   |  Summary                                 |
+============+================+============+==========================================+
| schema     | mydb.newschema | CREATE     | schema "demodb.newschema" was            |
|            |                |            | successfully created                     |
+------------+----------------+------------+------------------------------------------+
demodb.public/<no-store># LIST SCHEMAS;
+------------+-------------+------------+-------------------------------+
|  Name      |  Is Default |  Owner     |  Created At                   |
+============+=============+============+===============================+
| public     | true        | sysadmin   | 2023-08-09 17:14:46 +0000 UTC |
+------------+-------------+------------+-------------------------------+
| newschema  | false       | sysadmin   | 2024-07-02 21:20:23 +0000 UTC |
+------------+-------------+------------+-------------------------------+
```

#### Create a new schema in a specified database

The following creates a new schema named `NewSchema` in the specified database `otherdb`:

```sh
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-07-02 21:21:18 +0000 UTC |
+------------+-------------+------------+-------------------------------+
| NewSchema  | false       | sysadmin   | 2024-07-02 21:21:25 +0000 UTC |
+------------+-------------+------------+-------------------------------+
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.deltastream.io/reference/sql-syntax/ddl/create-schema.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
