CREATE SCHEMA Statement

Defines a named schema that can be referenced later and reused by one or more streams/windows in the project or module.

Syntax

CREATE SCHEMA name {(columname type [,...])|
		INHERITS [FROM] schema_name [,...] [(columname type [,...])]};

Components

name

An identifier that is referenced while defining stateless or stateful elements.

columnname

The unique name of a column.

type

The datatype of the specified column.

schema_name

The name of another schema.

Usage

The CREATE SCHEMA statement defines a named schema that can be referenced by stateful and stateless elements such as streams or windows. You can define the schema as an inline schema definition, or so that it inherits the definition from another schema.

You can extend a schema by setting it up to inherit an existing schema definition and appending more columns. Additional columns you specify are appended to the inherited schema. Otherwise, the inherited schema definition remains an exact replica of the specified named schema. Alternatively, you can extend a schema by inheriting multiple schema definitions.

The concatenation of the schemas is implicit in the specified order. Additional columns are appended. These column names must be unique, otherwise an error is raised.

Examples

This creates two schemas, symbol_schema and trade_schema, which is extended from symbol_schema:

CREATE SCHEMA symbol_schema (Symbol STRING);
CREATE SCHEMA trade_schema INHERITS FROM symbol_schema (Price FLOAT);