How to Create a SQL Database with RDM


Posted by Kevin Hooks
On May 30, 2012

Every database management system has their way of creating a database. This 5 minute tutorial is aimed at initializing a database using RDM Workgroup. It covers the use of the rdmsql tool to create a database via importing a .sdl file and executing SQL Statements directly through the command line tool.

Creating a database via importing a .sdl file

This section will show you how to define and create a .sdl file. You will then use the RDM tool rdmsql to import the file and execute the statements, in return creating the database. If you do not have the SDK for RDM, you can download the free evaluation version here.

Structure a .sdl File

Inside of an .sdl file, you will define a series of SQL Statements, such as the SQL CREATE DATABASE statement, to execute to define and create your database including the tables and rows. The format will look similar to this.

/* First SQL Statement (SQL CREATE DATABASE Statement) */
CREATE DATABASE hello_worldJDBC;
/* Second SQL Statement (SQL CREATE TABLE Statement) */
CREATE TABLE hello_table
(
F00 char(31)
);

Taking a look at the above SQL Statements, you can see that it starts by creating a database with the SQL Statement format “CREATE DATABASE {database_name}”. The next statement creates the table “hello_table” with f00 being the only row in the table. Be sure to save the file, then proceed to the next step.

Compile a .sdl File

Raima Database Manager has a tool for executing SQL statements, which is exactly what the file above is doing. It is executing the required statements to create a simple database. The name of this tool is rdmsql. You will be using this tool through command line operations, which will be the same regardless of what platform you are on.

Step 1) Open a cmd prompt or terminal and navigate to the RDM installation directory. “/opt/Raima on linux or C:\Raima on Windows“.

Step 2) Set up the RDM environment by running “rdm.bat” on Windows or “. ./rdm.sh” on Linux.

Step 3) Navigate to the location of where you want your database stored.

Step 4) Run rdmsql –b “name_sdl_file“. The –b signifies that you will be passing the arguments in through a text file.

Ex: rdmsql –b hello_worldJDBC.sdl
*Note: hello_worldJDBC.sdl can be found in the Raima Install directory under “**\RDM\11.0\GettingStarted\tutorials\HelloWorldJDBC\”
This will generate all of the necessary database files under a folder call hello_worldJDBC.

Alternate Method: Execute SQL Statements Directly | Using the rdmsql Tool

The rdmsql tool can also be used to execute SQL statements directly via the command line interface to the tool.

Simply run the following command on the command line to start up the tool :

rdmsql

This will bring up the interface. The interface will look like the screenshot below.

Begin by creating a connection by typing this command into the tool:

.c 1

This creates connection handle 1.

Next, Execute your SQL Statements in order using the above statements from the .sdl as an example

Type the following:

CREATE DATABASE hello_worldJDBC;
CREATE TABLE hello_table(F00 char(31));
Commit;

*Note: make sure to add the commit on rdmsql otherwise your database will not be created*

Finally quit the tool by typing “.q” and your database will be ready to go! View the screenshot below for further reference.

You have now successfully initialized your database!

Now to create your first JDBC application.

References

Click the links below to view more information about SQL.
MSDN SQL Create Database Reference


Next Blog Posts

Leave Comment

Name*

E-mail*

Website

Message*