3.4. Testing the Database

At this point, you have enough information to create and test your database. Even without stored procedures, you can use the VoltDB shell commands and ad hoc queries to try out the database.

You start by compiling the schema in helloworld.sql into an application catalog and then starting the database on your local system. You use the voltdb command to both compile the catalog and start the database. The first command uses the compile action and specifies both the input schema file and the name of the resulting application catalog, helloworld.jar. The second command uses the create action, specifying the newly created catalog as input:

$ voltdb compile -o helloworld.jar  helloworld.sql
$ voltdb create catalog helloworld.jar

Congratulations! You have created your first VoltDB database. (Of course, if you receive any error messages when you compile the catalog or start the database, go back and make sure you have no typos in your source files or command lines.)

You can test the database to prove it is working by issuing ad hoc queries to the database using VoltDB's interactive command line. Create a new terminal session and start the interactive command prompt using the sqlcmd command.

By default, sqlcmd connects to the database on the local system. At the subsequent prompt you can enter SQL queries such as INSERT and SELECT. Be sure to include a semi-colon at the end of each query to tell sqlcmd to execute the command. For example:

$ sqlcmd
1> INSERT INTO HELLOWORLD VALUES(  'Hello','World', 'English');

(1 row(s) affected)
2> SELECT * FROM HELLOWORLD WHERE DIALECT='English';
HELLO  WORLD  DIALECT 
------ ------ --------
Hello  World  English 

(1 row(s) affected)
3> EXIT
$

These commands verify that records can be written and read from the database. Now that we are done with the test you can stop the database, either by performing a CTRL-C in the terminal session where you started the database, or using VoltDB's administrative command tool, voltadmin, from the terminal session you used to issue sqlcmd queries:

$ voltadmin shutdown

Although inserting and fetching records manually proves the database is operational, for real applications you will want to be able to access the database programmatically. The most efficient way to do this is through stored procedures. So let's see how you do that next.