Tuesday, 2 February 2010

Creating a Database ( Interbase Tutorial # 3 )

What is database ?

A database is like a container. You have some tables in the container. Each table related to others with some special ways, so the owner of the database can easily maintain or manipulate the tables.

To create new database we have to run InterBase Windows Interactive SQL from the start menu.

Choose Create database, then the Create Database Window appears.

Enter your database name, for example : c:\mydata\mydatabase.gdb
Enter your username and password then press OK.

Now you’ve got a database named ‘mydatabase.gdb’ in folder ‘mydata’ , but you haven’t got any tables in it.

Creating a table

A table always has some rows and columns. Where each row represent each record of your table and each column represent each field of your record.

For example

a record of the table above has four fields : ID, Name, Age and PhoneNumber

To create a table in interbase, you have to write some Structured Query Language (SQL) codes in the InterBase Interactive SQL window. The SQL codes to create the table above is shown below :

create table employee(
id integer not null,
name varchar(30) not null,
age integer not null,
phonenumber varchar(12) not null)

then execute your codes.
Now, see each field we have in the table ‘employee’ :

fields data type
id integer
name string (has maximum character = 30)
age integer
phonenumber string (has maximum character = 12)

not null’ means that each field must have a value

Now you already have a database contains a table named ‘employee’. You can create another table with the same way. The number of table depends on your need.

Creating a Database Using Text Editor

Another way to create a database, you can type your SQL codes in a text editor (ie : notepad) before you execute them in InterBase Interactive SQL window.

Type these SQL codes in the text editor, then save it with a name : ‘mydata.txt’.

create database 'c:\mydata\mydata.gdb'
user 'NEW_USER' password 'password';

create table employee(
id integer not null,
name varchar(30) not null,
age integer not null,
phonenumber varchar(12) not null);

Go to the InterBase Interactive SQL window and execute the codes by choosing File – Run an ISQL script. And choose your ISQL script file : ‘mydata.txt’. If your SQL script has no errors, the database ‘mydata.gdb’ will be created and it contains a table ‘employee’.

Go to Previous Tutorial or NextTutorial


  1. keeerrreeeennn....


  2. Repeatedly got the error
    SQLCODE = -904
    unavailable database

    Cannot see why!

  3. We zijn niet alleen een Chinese uitvoerende fabriek , maar verwacht ook:

    meer service.

    makkelijkere en heldere communicatie in uw eigen Nederlandse taal

    een berg aan know-how en ervaring op het gebied van materialen en kunststof product engineering.


These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.