CREATE SCHEMA statement

Defines a named schema that can be referenced later and reused by one or more queries in the module.

Syntax

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

name

The name of the schema.

col_name

A column name.

type

The CCL data type of the column.

schema_name

The name of another schema.

Usage

The named schema can inherit the column names and data types of one or more named schemas, created with Create Schema statements elsewhere in the same module. If you include an INHERITS clause in the schema definition, the new schema definition uses the column names and data types of the specified schemas as its first (left-most) columns, in the order listed, and adds any additional columns after the inherited columns.

Restrictions

See Also

Example

The following example creates a schema named trade_schema with two columns named Symbol and Price. The columns have data types of STRING and FLOAT, respectively.

CREATE SCHEMA trade_schema (Symbol STRING, Price FLOAT);

This example uses a different method to create the same schema for trade_schema as in the previous example. The schema inherits the Symbol column definition from symbol_schema, and then defines an additional Price column.

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