CREATE SCOPE

  • reference
    +
    The CREATE SCOPE statement enables you to create a scope.

    Syntax

    create-scope ::= 'CREATE' 'SCOPE' ( namespace ':' )? bucket '.' scope ( 'IF' 'NOT' 'EXISTS' )?
    Syntax diagram: refer to source code listing
    namespace

    (Optional) An identifier that refers to the namespace of the bucket in which you want to create the scope. Currently, only the default namespace is available. If the namespace name is omitted, the default namespace in the current session is used.

    bucket

    (Required) An identifier that refers to the bucket in which you want to create the scope.

    scope

    (Required) An identifier that refers to the name of the scope that you want to create. Refer to Naming for Scopes and Collections for restrictions on scope names.

    If there is a hyphen (-) inside the bucket name or the scope name, you must wrap that part of the path in backticks (` `). For example, default:`travel-sample` indicates the travel-sample keyspace in the default namespace.

    IF NOT EXISTS Clause

    The optional IF NOT EXISTS clause enables the statement to complete successfully when the specified scope already exists. If a scope with the same name already exists within the specified bucket, then:

    • If this clause is not present, an error is generated.

    • If this clause is present, the statement does nothing and completes without error.

    Example

    This statement creates a scope called events in the travel-sample bucket.

    CREATE SCOPE `travel-sample`.events