The example in step 4 demonstrates one of the advantages of using a configuration file to start xSQL with a pre-designed set of instructions. A database schema can be defined as in
shard1.cfg
:# # Simple In-Memory configuration # database_name : imdb, database_size : 20m, runtime_configuration : { debug_library : false, disk_support : false, shared_memory : false, transaction_manager : mursiw }, schema : " #define uint2 unsigned<2> declare database locatedb; class Employee { string name; uint2 dept_no; unique tree<name> Iname; tree<dept_no> Idept; }; ", db_params: { mem_page_size : 512 }, sql_trace : false, sql_port : 5500(Here the schema definition uses standard eXtremeDB DDL.)
Note that the communication port is defined also here as
sql_port : 5500
. Inshard2.cfg
the port is defined assql_port : 5501
. SQL statements can be executed also in the config file to initialize the state of the database at startup. For example, notice thesql_statements
section inclient.cfg
:{ remote_client : [ "127.0.0.1:5500", "127.0.0.1:5501"], sql_statements : " 1:INSERT INTO Employee(name, dept_no) VALUES('Luke Skywalker', 1); 1:INSERT INTO Employee(name, dept_no) VALUES('Han Solo', 1); 2:INSERT INTO Employee(name, dept_no) VALUES('Darth Vader', 2); " }Note that the
IP
andport
numbers (127.0.0.1:5500
,127.0.0.1:5501
) for both servers are specified, then the SQLinsert
statements use of node identifiers "1:
" and "2:
" to indicate which shard to insert the data into. Many other config file capabilities are demonstrated in the SDKsamples/xsql/configs
directory. These samples are explained in the xSQLSamples topic and a full description of config file options is detailed in the xSQL Startup Options.The next step in this Tutorial will demonstrate how to export and import data from external files using xSQL.