3. Getting Started Using OpenROAD : Simple Client Applications : How You Can Create a Simple Client/Server Application : Create a Table in the Database
 
Share this page                  
Create a Table in the Database
To create a table in a database, you must first have created a database (or use an existing database) and must have created a database connection profile.
In this procedure, you will create and populate a project table with two records of data. But first you must connect to a database in which you can create a new table for the purposes of this demonstration procedure.
To create a table in the database
1. Click the Query tab.
OpenROAD connects to the selected database profile.
2. Open the Connection Profiles folder in the Database Connections portlet.
3. Open the database folder for the database in which you want to create a table.
4. Right-click on the database name and select Connect.
The Database Query portlet becomes active and displays the connection information.
5. Click in the Database Query portlet to make it active.
6. Enter the following code to create the project table:
create table project(
project_id integer not null,
project_name varchar(40) not null,
assigned_to varchar(15) not null,
level_of_effort date not null default ' ',
due_date date not null default ' ',
start_date date not null default ' ',
date_completed date not null default ' ')
7. Click the run icon on the toolbar to execute the SQL statement.
Results are displayed in the Query Results portlet. (The table with three columns is created.)
8. Clear the contents of the Database Query portlet and then enter the following code:
insert into project (project_id,project_name,assigned_to) values (1,'Requirements Definition','Mary');
commit;
insert into project (project_id,project_name,assigned_to) values (2,'System Design','Larry');
commit;
Click the Run icon on the toolbar.
Results are displayed in the Query Results portlet. (Two records were added to the table.)
9. Enter following statement in the Database Query portlet:
select * from project
Click the Run icon.
The contents of the table are displayed in the Query Results portlet. For example:
10. Enter the following final command in the Query Results portlet, and run it:
commit;
11. Disconnect the database session by right-clicking on the database session in the Database Connections portlet and selecting Stop.
You are now ready to create an application and connect it to the database you created.