My previous post on VoltDB went over installing the product. In this post, I was going to go over creating a database and working with data.
Creating and Starting database:
First, you put together a SQL script with the schema definition. For my test, I just created a couple of tables, using standard data types (int, varchar, etc.), then save the SQL script to my home directory.
Second, compile the schema definition into what VoltDB calls an ‘Application Catalog’. From the command line, run:
voltdb compile -o test.jar test.sql
where test.sql is the table definitions put together in step 1, and test.jar is the output file.
This step will also create insert, update and delete procedures for each table. Commands and file names in the terminal emulator are case-sensitive.
Third, the JAR database definition is used to start the database. From the command line, run:
voltdb create test.jar
Once you see ‘Server completed initialization’ then the database is ready to use. In the command window, select ‘File’ => ‘Open Tab’ to open a 2nd command window. Run command:
to see the version number.
Working With Data:
In that same 2nd window, run the command:
to start the SQL command interface. You should see ‘SQL Command :: localhost:21212’ (21212 is the default port) and then a new line with ‘1>’. From here you can execute SQL commands against the database. Be sure to use a semicolon at the end of each command
To leave the SQL Command window type:
And to stop the database service: