The following sections demonstrate a number of useful xSQL commands.
For an overview see page xSQL Commands
ha getmode
When using xSQL as a eXtremeDB High Availability MASTER or REPLICA, the
ha getmode
displays the current HA role of the xSQL instance. For MASTER it also prints out the HA mode flags:XSQL>ha getmode Running in MASTER mode, options are : HOTSYNCHThe corresponding function
xsql_ha_get_mode()
returns the sum of MCO_HAMODE_* flags when xSQL is running in MASTER mode, 0 when running in REPLICA mode.sleep
As explained in the xSQL tutorial, it is sometimes useful to write a set of SQL statements in a script file, and then execute the script with the
script
command. But sometimes it may be necessary to pause for some small amount of time between SQL statements. For example, suppose we have a script file like the following that inserts a record on one cluster node and then queries data on another node to verify that the change has been propagated. Here a brief pause is required between those two lines which is implemented with thesleep
command:File test_sleep.sql 1:create table t(n int); 1:insert into t values([1,2,3]); sleep 3 2:select * from t;echo
When running script files it may be useful to display progress or status information during the execution of the script. The
echo [string]
command is provided for this purpose. It writes a string argument to standard output (similar toecho
found in bash or any other UNIX shells). For example, the abovetest_sleep
script could be modified as follows:File test_sleep.sql 1:create table t(n int); 1:insert into t values([1,2,3]); echo Sleep for 3 seconds sleep 3; 2:select * from t;help
The
help
command displays a brief syntax description of xSQL commands. For example:XSQL>help <sql-statement>';' any valid SQL statement dumplog <file-path> Dump XSQL logs on the server side xlog [bynode|byquery] [all]Show server's logs cluster Cluster related commands sleep Do sleep for N seconds shutdown Shutdown database server save <file-path> Save database image to specified file saveclass <file-path> <table-name>Save table content to the specified file loadclass <file-path> [ <table-name> ]Load table content from the specified file savemeta <file-path> Save database metadata to specified file savedict <file-path> Save database dictionary to specified file detach Do not close database on exit (leave it in shared memory) backup <database-file-path> <log-file-path> <n-threads=1>Online backup of disk database to the specified files mem [-b|-k|-m|-g|-t|-p] Show memory usage in bytes (-b), Kb (-k, default), Mb (-m), Gb (-g), Tb (-t) or memory pages (-p) memddl Show dictionary memory usage exit Terminate interactive SQL session pause Pause interactive SQL session trace (on|off) Toggle query execution trace progress (on|off) Show progress of query execution input (<file>|console) Redirect input from specified file script <file-path> Execute SQL script from specified file output [<file>|console|null]Redirect output to specified file logsession (on|off) [<file>]Save session to specified file format (TEXT|HTML|XML|CSV [delimiter 'C'][header on|off]|LIST)Select query output format dtformat FORMAT Output date/time format (see strftime) numformat FORMAT Output real number format (see sprintf) strformat width=<N> Set width for string fields seqformat {default|short|long} [<first> <last>]Output sequences format. arrayformat {default|short|long} [<first> <last>]Output arrays format. nullformat NULLSTR String representation for null values help Print supported commands echo Print arguments import TABLE CSV-FILE [(use|skip) header] [commit N]Import data from CSV file