We have moved to www.dataGenX.net, Keep Learning with us.

Tuesday, June 19, 2012

DB2 : some basic commands

Hi Guys
Today I am going to ask a question, what you will do if you have to install DB2 on more than 100 systems ?? or did you ever think abt why DB2 give you a response file after selecting installation param ??
For this case, here is the solution :
$ setup -u <response_file>
This will automatically pick all the values from the response file

So Here I am sharing some basic but important DB2 commands. Please go through ...........

Verify the DB2 version:

db2level

Display all DB2 products with available licenses installed.
 db2licm –l 

to list the installed DB2 on system
db2swtch -l --  Displays a list of DB2 database product installations on the system.
db2swtch -d installation-name  --- Sets the default DB2 copy.

For launching the Db2 first step

$ db2fs

for DB2 control center
$ db2cc

Create the DB instance

db2icrt <instance_name>

Create the DB instance [In Linux]
/home/db2inst1/instance> ./db2icrt -u db2fenc2 db2inst2
db2fenc2 and db2inst2 must exist before hand.

to list the instance list
db2ilist

to get the current active instance
db2 get instance

to set the instance
set db2instance=<instance_name>

Linux (syntax depends on shell)
export DB2INSTANCE=<instance_name>


for start the db instance after setting the instance
db2start

to create database
create db <db_name> [As dbAlias ON drive <drive_name>]
create database <db_name> [As dbAlias ON drive <drive_name>]

to create database [In Linux]
create db <db_name> [As dbAlias ON path <drive_name>]
create database <db_name> [As dbAlias ON drive <drive_name>]

Connect to a DB
connect to <dbname> user <username> using <userpswd>

to chk the connection
db2 connect

to drop a connection with databse
connect reset

to drop a database

drop db <db_name>

to stop the instance current active instance
db2stop [force]

to drop instance
db2idrop <instance_name>
db2idrop -f <instance_name>  -- forcefully delete instance

to drop instance [In Linux]
db2stop (as the instance owner, eg: db2inst1)
/opt/ibm/db2/V9.5/instance> ./db2idrop db2inst1 (as root)

Hoping these commands will help you in day to day task.
Will come with more and interesting commands.

njoy the simplicity.......
Atul Singh

victimizeit.blogspot.com

No comments :

Post a Comment