Using SQL commands
You can use CREATE TABLE command in SQL to create NoSQL tables.
Example 1: The following CREATE TABLE statement defines a
BaggageInfo
table that holds baggage information of passengers in
an airline
system.CREATE TABLE BaggageInfo (
ticketNo LONG,
fullName STRING,
gender STRING,
contactPhone STRING,
confNo STRING,
bagInfo JSON,
PRIMARY KEY (ticketNo)
)
Example 2: The following CREATE TABLE statement defines a
stream_acct
table that holds data from a TV streaming
application.CREATE TABLE stream_acct(
acct_id INTEGER,
profile_name STRING,
account_expiry TIMESTAMP(1),
acct_data JSON,
PRIMARY KEY(acct_id)
)
Example 3: The following CREATE TABLE statement defines a
stream_acct_new
table that holds data from a TV streaming
application. The rows of the table expire in 2
days.CREATE TABLE stream_acct_new(
acct_id INTEGER,
profile_name STRING,
account_expiry TIMESTAMP(1),
acct_data JSON,
PRIMARY KEY(acct_id)) USING TTL 2 days
Example 4: The following
CREATE TABLE statement defines a
storeAcct
table, which is
a JSON collection table created for a shopping application. This table
includes the contactPhone
as the primary key field of the
type
string.CREATE TABLE storeAcct(
contactPhone string,
primary key(contactPhone)) AS json collection
To insert data into the tables, see Inserting, Modifying, and Deleting Data.