Appendix B. Table Data Definition Language Overview

Before you can write data to tables in the store, you must provide a definition of the tables you want to use. This definition includes information such as the table's name, the name of its various rows and the data type contained in those rows, identification of the primary and (optional) shard keys, and so forth. To perform these definitions, Oracle NoSQL Database provides a Data Definition Language (DDL) that you use to form table and index statements. These statements can be used to:

Table and index statements take the form of ordinary strings, which are then transmitted to the Oracle NoSQL Database store using the appropriate method or function. For example, to define a simple user table, the table statement might look like this:

CREATE TABLE Users (
    id INTEGER,
    firstName STRING,
    lastName STRING,
    contactInfo JSON,
    PRIMARY KEY (id)
) 

For information on how to transmit these statements to the store, see Introducing Oracle NoSQL Database Tables and Indexes.

For overview information on primary and shard keys, see Primary and Shard Key Design.

For overview information on indexes, see Creating Indexes.

The remainder of this appendix describes in detail the DDL statements that you use to manipulate table and index definitions in the store.

Name Constraints

The following sections use all uppercase to identify DDL keywords (such as STRING, CREATE TABLE, and so on). However, these keywords are actually case-insensitive and can be entered as lower-case.

The DDL keywords shown here are reserved and cannot be used as table, index or field names.

Table, index and field names are case-preserving, but case-insensitive. So you can, for example, create a field named MY_NAME, and later reference it as my_name without error. However, whenever the field name is displayed, it will display as MY_NAME.

Table and index names are limited to 32 characters. Field names can be 64 characters. All table, index and field names are restricted to alphanumeric characters, plus underscore ("_"). All names must start with a letter.