Previous Next JavaScript must be enabled to correctly display this content

## CREATE NAMESPACE Statement

You can add a new namespace by using the CREATE NAMESPACE statement.

Syntax

    create_namespace_statement ::=
       CREATE NAMESPACE [IF NOT EXISTS] namespace_name

    namespace_name ::= name_path
    name_path ::= field_name ("." field_name)*
    field_name ::= id | DSTRING

Semantics

IF NOT EXISTS: This is an optional clause. If you specify this clause, and if a namespace with the same name exists, then this is a noop and no error is generated. If you don't specify this clause, and if a namespace with the same name exists, an error is generated indicating that the namespace already exists.

Note:

Namespace names starting with sys are reserved. You cannot use the prefix sys for any namespaces.

Example 3-1 Create Namespace Statement

The following statement defines a namespace named ns1.

    CREATE NAMESPACE IF NOT EXISTS ns1

Create Table in the namespace ns1 as follows:

    CREATE TABLE ns1:t (id INTEGER, name STRING, primary key (id))

    INSERT INTO ns1:t VALUES (1, 'Smith')

    SELECT * FROM ns1:t

Output:

    {"id":1,"name":"Smith"}