Description of the correct procedure for getting started with DB2

Source: Internet
Author: User
Tags db2 describe table db2 express

Using with Instances and Databases) the correct operation process. If you are interested in the correct operation process of the DB2 getting started Experiment Working with Instances and Databases, it will be of great help in future studies or work.

Working, Databases, Instances, getting started, Experiment Working, Databases, Instances, DB2 getting started, experiment

Follow these steps to use db 2 express 9

 
 
  1. DB2 Migration Workshop  
  2. LAB 1 – Working with Instances and Databases (Solution)  
  3. Expected duration: 45 mins  
  4. This lab will help you solidify concepts of instances and databases. It is to be completed BEFORE the presentation “DB2 Instances and Databases”.  
  5. The following commands are demonstrated:  
  6. DB2icrt ACTIVATE DB FORCE APPLICATION  
  7. DB2idrop DEACTIVATE DB GET CONNECTION STATE  
  8. DB2ilist CONNECT LIST APPLICATIONS  
  9. DB2start CONNECT RESET LIST DB DIRECTORY  
  10. DB2stop CREATE DATABASE LIST TABLES  
  11. DB2admin start DROP DATABASE   
  12. DB2admin stop DESCRIBE TABLE   
  13. Prerequisites:  
  14. · DB2 Version 8 Server has been installed  
  15. Highly Recommended: Before each step in this lab, locate the demonstrated command in the CLP quick reference and mark it with an asterix (*).   
  16. This will help you get familiar with the DB2 CLP cheat sheet.  
  17. Note: On Linux/UNIX, you can switch users (su) without logging out by using:  
  18. su – .. to switch to root user (dash is important!)  
  19. su – [userid] .. to switch to non-root user (dash is important!)  
  20. exit .. to exit switch back  

1. Windows: Launch the DB2 Command Window. Start the Command line Window of DB2)

In this experiment, I used the DB2admin account automatically created during the installation of DB2 express 9)

 
 
  1. Start> Programs> IBM DB2> Command Line Tools> Command Window
  2. (Or simply, DB2cmd)
  3. Linux: Login to the operating system as user DB2inst1linux, you need to use DB2inst1 for Login)
  4.  

2. When DB2 is installed, no database exists. Create the SAMPLE database provided by DB2.

 
 
  1. DB2sampl 

In DB2 express9, the database already exists)

3. Verify that a database now exists. Show the contents of the database directory:

Show all database commands

 
 
  1. DB2 list db directory
  2. Fill in the following information from the database directory:
  3. Database alias SAMPLE
  4. Directory entry type Indirect Directory entry type: Indirect)

4. DB2 does not have database users. instead, DB2 uses userIDs and passwords defined at the operating system (or network authentication facilities) to authenticate users. connect to the SAMPLE database using the userID logged into the operating system.

It seems that DB2 9 has been able to automatically create a system account as its own database account.

Connect to database simple:

 
 
  1. DB2 connect to sample 

5. See all connections that currently exist for the current instance

Display All the DB2 entry-level applications running on the current database instance

 
 
  1. DB2 list applications  
  2. Fill in the following information:  
  3. Application name: DB2bp.exe  
  4. Application handle: 2 (your answer may vary)  
  5. Database name: SAMPLE  

6. Disconnect from the database:

Disconnect

 
 
  1. DB2 connect reset 

7. Connect to the SAMPLE database using a specific userID and password.

 
 
  1. DB2 connect to sample user <userid> using <password> 

8. View the tables that currently exist in the SAMPLE database

 
 
  1. DB2 list tables: displays the tables created by the user)
  2. Or
  3. DB2 list tables for all show all tables including user and System)

9. From the output of list tables, you shocould see that a table called EMPLOYEE exists. Find out the structure of EMPLOYEE

 
 
  1. DB2 describe table employee does not exist)
  2. What is the maximum length of JOB column? 8 characters
  3. What is the data type for the Salary Column? DECIMAL (9, 2)
  4. The above two questions are indented to show how data type lengths from the output

    Describe table are interpreted differently for numeric and character types.

10. Attempt to stop the instance. You shocould get an error because connections still exist.

 
 
  1. DB2stop  
  2. What is the SQLCODE associated with the error message? SQL1025N  

11. To stop the instance, we have to get rid of the current connections. In this step, forcibly disconnect all applications.

 
 
  1. DB2 force applications all  
  2. DB2stop  
  3. note: you can also force applications by application handle using:  
  4. force application (

12. By using force application, you have terminated your own connection. Attempt to SELECT from the employee table.

 
 
  1. DB2 “select * from employee”  
  2. You should get the error code SQL1224N. Check your connection state.  

Get connection status

 
 
  1. DB2 get connection state 

Can be connected and has been closed. The above content is an introduction to the DB2 getting started Experiment Working with Instances and Databases. I hope you will gain some benefits.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.