Express-C: Starting
1. Introduction
I’m writing this to help newbies starting Express-C.
First of all you’ll need to install a free version of DB2. You can get an old but functional deb here or you can click here to get an up to date how-to installation guide.
To start using Express-C and DB2 in general you need to know something about it’s hierarchy: the master’s name is DAS and the databases admins are known as instances. As you can see in the figures below, you can have multiple instances with several databases inside. There is only and only one DAS per installation and one or multiple instances (database managers).
(you should click to enlarge them)
2. Starting
In UNIX installations DAS and instances are just ordinary UNIX users with some profile specifications. So, you will need to switch to one of those users and load the profile:
geko@hydra:~$ ls /home/ cesium dasusr1 db2fenc1 db2inst1 geko geko@hydra:~$ su db2inst1 Password: hydra:~$ . sqllib/db2profile hydra:~$
Note that the creation of instances is not covered in this tutorial, however if you have installed the deb one instance was created.
Before we can work in a valid instance, we need to start one. In the deb installation you can run:
hydra:~$ /opt/ibm/db2exc/V9.1/adm/db2start SQL1063N DB2START processing was successful.
…and to stop it:
hydra:~$ /opt/ibm/db2exc/V9.1/adm/db2stop SQL1064N DB2STOP processing was successful.
3. Just a tip
If you are a smart guy (ok, lazy) you can change where you shell looks for programs. You can do that editing instance’s profile. In our case:
hydra:~$ echo "PATH=$PATH:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm" \ >> ~/sqllib/db2profile
4. DB2 interpreter
This is the situation: we are logged as a valid instance and we have started it. To use the db2 interpreter and start testing db2/sql commands you should type:
hydra:~$ db2 (c) Copyright IBM Corporation 1993,2002 Command Line Processor for DB2 ADCL 9.1.2 -- omited output -- To exit db2 interactive mode, type QUIT at the command prompt. Outside interactive mode, all commands must be prefixed with 'db2'. To list the current command option settings, type LIST COMMAND OPTIONS. For more detailed help, refer to the Online Reference Manual. db2 =>
Just as an introduction I’ll show you some valid commands.
4.1 Create database
In DB2 Express-C, only Unicode databases can store both XML documents and more traditional forms of SQL. Although this tutorial doesn’t cover XML stuff you should keep that in mind because that’s the exact reason why DB2 is so powerful. All commands are similar to SQL syntax. For instance:
create database test using codeset UTF-8 territory us
and
connect to test; create table items ( id int primary key not null, name varchar(30), stuff xml );
5. Conclusion
As I’m just learning, this is all i can give you. All i can promise you is that the more i learn the more i teach.
Get in touch for more advanced tutorials.


January 8th, 2008 at 22:36
[...] assume that you read the Express-C: Starting tutorial so that i can use the test.items as my table [...]
January 11th, 2008 at 00:26
[...] assume that you read the Express-C: Starting tutorial so that I can use the test.items as my table [...]
February 26th, 2008 at 05:02
[...] Starting with DB2 Express-C [...]
October 15th, 2008 at 18:37
Hi
when I try to connect to db2 with rails I am getting this error…
SQL30082N Security processing failed with reason “15″ (“PROCESSING FAILURE”). SQLSTATE=08001 SQLCODE=-30082
I have just setup db2 9.5 on ubuntu. I am using db2inst1 and password corresponding to it. Please help me fixing this. Thanks in advance.