Defining a Table
Administrators define tables as needed to structure data. To define a table within the data grid, complete this task.
The examples in these steps illustrate adding commands to a configuration script. When the script is complete, the administration tool executes the script to define the table.
Alternatively, you can execute each step immediately as a separate administration tool command, instead of accumulating them in a script.
Either the realm must contain a valid data grid definition, or your configuration script file must contain commands to create a valid data grid definition.
- Procedure
- In a text editor, either begin editing a script file, or continue adding commands to an existing script.
Follow the convention of naming your script with the .tibdg file name extension.
- Add a script command to create the table. For example:
table create table_namekey_column_namekey_column_type
table create table_namekey_col_1col_1_typekey_col_2col_2_type
Every table requires a primary key, which can consist of one or more columns. The first example creates a key with one column. The second example creates a key with two columns.The data type of key columns must be either long or string. - Define additional columns.
For each column in the table, add a script command to create the column. For example:
column create table_namecolumn_namecolumn_type
Only the following FTL datatypes are valid as column types:- Long
- Double
- String
- DateTime
- Opaque
- Optional. Define secondary indexes.
For each index in the table, add a script command to create the index. For example:
index create table_nameindex_namecolumn_name
index create table_nameindex_namecolumn_1column_2column_3
The data type of index columns must be either long or string. - Run the script to create the tables in the data grid.
tibdg -s script_file_path
You can repeat this task to define additional tables. After creating the table, grant users or roles permissions to read from or write to the table.