對DB2入門實(shí)驗(yàn)的正確操作流程的描述
http://database.51cto.com/art/200608/29669.htm以下的文章主要向大家講述的是DB2入門實(shí)驗(yàn)(Working with Instances and Databases )的正確操作流程,相信如果你對DB2入門實(shí)驗(yàn)(Working with Instances and Databases )的正確操作流程有興趣了解的話,會(huì)在以后的學(xué)習(xí)或是工作中帶來很大的幫助。
Working, Databases, Instances, 入門, 實(shí)驗(yàn)Working, Databases, Instances, DB2入門, 實(shí)驗(yàn)
按照以下步驟完成,使用了db 2 express 9
- DB2 Migration Workshop
- LAB 1 – Working with Instances and Databases (Solution)
- Expected duration: 45 mins
- This lab will help you solidify concepts of instances and databases. It is to be completed BEFORE the presentation “DB2 Instances and Databases”.
- The following commands are demonstrated:
- DB2icrt ACTIVATE DB FORCE APPLICATION
- DB2idrop DEACTIVATE DB GET CONNECTION STATE
- DB2ilist CONNECT LIST APPLICATIONS
- DB2start CONNECT RESET LIST DB DIRECTORY
- DB2stop CREATE DATABASE LIST TABLES
- DB2admin start DROP DATABASE
- DB2admin stop DESCRIBE TABLE
- Prerequisites:
- · DB2 Version 8 Server has been installed
- Highly Recommended: Before each step in this lab, locate the demonstrated command in the CLP quick reference and mark it with an asterix (*).
- This will help you get familiar with the DB2 CLP cheat sheet.
- Note: On Linux/UNIX, you can switch users (su) without logging out by using:
- su – .. to switch to root user (dash is important!)
- su – [userid] .. to switch to non-root user (dash is important!)
- exit .. to exit switch back
1. Windows: Launch the DB2 Command Window. (啟動(dòng)DB2的命令行窗口)
(在本次實(shí)驗(yàn)中,我使用的是DB2 express 9在安裝過程中自動(dòng)創(chuàng)建的DB2admin帳戶登陸)
- Start > Programs > IBM DB2 > Command Line Tools > Command Window
- (or simply, DB2cmd)
- Linux: Login to the operating system as user DB2inst1(linux下需要使用DB2inst1登陸)
2. When DB2 is installed, no database exists. Create the SAMPLE database provided by DB2.
- DB2sampl
(在DB2 express9該數(shù)據(jù)庫已經(jīng)存在)
3. Verify that a database now exists. Show the contents of the database directory:
顯示所有的數(shù)據(jù)庫的命令
- DB2 list db directory
- Fill in the following information from the database directory:
- Database alias SAMPLE
- 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.
似乎DB2 9已經(jīng)可以自動(dòng)創(chuàng)建系統(tǒng)帳戶作為它自身的數(shù)據(jù)庫帳戶。
連接到數(shù)據(jù)庫simple:
- DB2 connect to sample
5. See all connections that currently exist for the current instance
顯示所有的運(yùn)行在當(dāng)前數(shù)據(jù)庫實(shí)例上的DB2入門應(yīng)用程序
- DB2 list applications
- Fill in the following information:
- Application name: DB2bp.exe
- Application handle: 2 (your answer may vary)
- Database name: SAMPLE
6. Disconnect from the database:
斷開連接
- DB2 connect reset
7. Connect to the SAMPLE database using a specific userID and password.
- DB2 connect to sample user <userid> using <password>
8. View the tables that currently exist in the SAMPLE database
- DB2 list tables (顯示用戶創(chuàng)建的表)
- or
- DB2 list tables for all(顯示所有的tables包括用戶和系統(tǒng)的)
9. From the output of list tables, you should see that a table called EMPLOYEE exists. Find out the structure of EMPLOYEE
- DB2 describe table employee (不存在)
- What is the maximum length of JOB column? 8 characters
- What is the data type for the Salary Column? DECIMAL(9,2)
- The above two questions are indented to show how data type lengths from the output of
DESCRIBE TABLE are interpreted differently for numeric and character types.
10. Attempt to stop the instance. You should get an error because connections still exist.
- DB2stop
- 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.
- DB2 force applications all
- DB2stop
- note: you can also force applications by application handle using:
- force application (<handle>)
12. By using FORCE APPLICATION, you have terminated your own connection. Attempt to SELECT from the employee table.
- DB2 “select * from employee”
- You should get the error code SQL1224N. Check your connection state.
獲取連接狀態(tài)
- DB2 get connection state
可連接并且已經(jīng)被關(guān)閉,以上的相關(guān)內(nèi)容就是對DB2入門實(shí)驗(yàn)(Working with Instances and Databases )的介紹,望你能有所收獲。
【編輯推薦】
- 對DB2數(shù)據(jù)移動(dòng)方法的正確解析
- 對DB2 增量備份的正確運(yùn)用描述
- DB2 并行版本中的查詢優(yōu)化登峰造極!
- DB2***SQL性能調(diào)節(jié)技術(shù)經(jīng)典版
- DB2性能調(diào)優(yōu)中易出現(xiàn)的問題有哪些?