createIMOLTPTable

Syntax

createIMOLTPTable(dbHandle, table, tableName, primaryKey, [secondaryKey], [uniqueFlag])

Details

Create an IMOLTP table in an IMOLTP database.

Arguments

dbHandle is a database handle returned by the database function.

table is a table object whose schema is used to define the schema for the new IMOLTP table.

tableName is a STRING scalar indicating the IMOLTP table name.

primaryKey is a STRING scalar or vector that specifies the primary key column(s).

secondaryKey (optional) is a STRING scalar or vector that specifies the secondary key column(s).

uniqueFlag(optional) is a Boolean scalar or vector, indicating whether each secondary key is unique. When uniqueFlag is a vector, the size of secondaryKey and uniqueFlag must be the same.

Examples

First, create an IMOLTP database.

dbName = "oltp://test_imoltp"
db = database(directory=dbName, partitionType=VALUE, partitionScheme=1..100, engine="IMOLTP")

(1) Create an IMOLTP table "test_table_1" and define a primary key on the column "id".

pt1 = createIMOLTPTable(
    dbHandle=db,
    table=table(1:0, ["id", "val1", "val2", "sym"], [LONG, INT, LONG, STRING]),
    tableName="test_table_1",
    primaryKey=`id
)

(2) Create an IMOLTP table "test_table_2". Define a primary key on columns "id" and "sym" and unique secondary keys on "val2" and "sym".

pt2 = createIMOLTPTable(
    dbHandle=db,
    table=table(1:0, ["id", "val1", "val2", "sym"], [LONG, INT, LONG, STRING]),
    tableName="test_table_2",
    primaryKey=`id`sym,
    secondaryKey=`val2`sym,
    uniqueFlag=true
)

(3) Create an IMOLTP table "test_table_3". Define a primary key on the column "id", non-unique secondary key on "val1" and unique secondary key on "sym".

pt3 = createIMOLTPTable(
    dbHandle=db,
    table=table(1:0, ["id", "val1", "val2", "sym"], [LONG, INT, LONG, STRING]),
    tableName="test_table_3",
    primaryKey=`id,
    secondaryKey=`val1`sym,
    uniqueFlag=[false, true]
)