User Tools

Site Tools


software:db2:start

This is an old revision of the document!


Instructions for accessing DB2 in Prism Labs


DB2 is running in the PRISM lab for EECS3421 students. The database name uses the format c3421 and the section code eg c3421a. The database assigned to you will be according to the section code you are in. Every semester the databases are regenerated.
Using db2
You have two ways to go.

  1. Entering into a db2 shell and working there
  2. issuing all your db2 commands from your UNIX shell. The choice is yours!


The db2 shell
At your UNIX command prompt, type:

    % db2 
Now you are in! You'll get some messages telling you some current status about the system. Then you will get a db2 prompt that looks something like "db2 => ". You can issue database manager commands and SQL statements while here. Some useful db2 commands: 
db2 => list database directory 	Lists all the databases that exist on the system. 
db2 => connect to c3421a 	Connect to our section's database. 
db2 => create table first (id int) 	Creates a table called first with one attribute id of type integer.
db2 => insert into first values(1) 	Inserts a tuple into first. 
db2 => select * from first 	Selects all tuples from first. 
db2 => drop table first 	Removes first from the database.
This is a powerful and dangerous command!
db2 => connect reset 	This drops your connection to the database.
You should always do this before leaving.
db2 => terminate 	Terminate current session and exit db2 interactive mode. 
Always leave your session this way!
software/db2/start.1485283939.txt.gz · Last modified: 2017/01/24 13:52 by seela