>db2 command (for linux)

  

DB2 learning documentation

(a) DB2 installation instructions: ===================== ====================== [root@fedora home]# ./db2_install

Specify one or more of the following keywords, separated by spaces , to install DB2 products. Keyword Product Description DB2.ESE DB2 Enterprise Server Edition for LINUX DB2.ADMCL DB2 Administration Client for LINUX DB2.ADCL DB2 Application Development Client for LINUX Enter "help" to redisplay product names. Enter "quit" To exit. *********************************************** ************ DB2.ESE The installation logfile can be found in /tmp/db2_install_log.3439. db2_install program completed successfully.

(b) Description of the instance === ======================================================= Before creating an instance, first create a group and user [root@fedora home]# groupadd wangzm [root@fedora home]# groupadd wzm [root@fedora home]# useradd -g wangzm -d -m /home/wangzm -p 123456 Wangzm [root@fedora home]# user Add -g wzm -m -d /home/wzm -p 123456 wzm

(2.)Creation of instance [root@fedora home]# /opt/IBM/db2/V8.1/instance/db2icrt -u wangzm wzm DBI1070I Program db2icrt completed successfully.

(3.) Database startup [root@fedora home]# su - wzm [wzm@fedora ~]$ db2start 05/20/2006 14:27: 39 0 0 SQL1063N DB2START processing was successful. SQL1063N DB2START processing was successful. (4.) Process of db2 wzm 5981 0.0 14.1 121364 17808 pts/0 S 14:27 0:00 db2sysc wzm 5987 0.0 13.6 121364 17108 pts/0 S 14 :27 0:00 db2ipccm wzm 5988 0.0 14.1 121364 17808 pts/0 S 14:27 0:00 db2resync wzm 5989 0.0 12.9 118820 16228 pts/0 S 14:27 0:00 db2srvlst wzm 5991 0.2 18.8 138584 23760 pts/0 Sl 14:27 0:01 db2hmon ,0,0,0,1,0,0,0,1e014,2,0,1,9fe0,0x11250000,0x11250000,15fc000,98006,2,138017 wzm 6204 0.0 6.0 35996 7624 pts /0 S 14:31 0:00 /home/wzm/sqllib/bin/db2bp 5846A513 5 A wzm 6285 0.0 14.2 121364 17864 pts/0 S 14:32 0:00 db2agent (idle) (5.) Display of the instance - ---Show all [wzm@fedora ~]$ db2ilist db2inst1 dl Qing wzm (6.) shows the current instance [wzm@fedora ~]$ db2 get instance The current database manager instance is: wzm [wzm@fedora ~]$

(7.) delete an instance [root @fedora ~]# /opt/IBM/db2/V8.1/instance/db2idrop qing DBI1070I Program db2idrop completed successfully. (8.) List which databases are in the current instance [wzm@fedora ~]$ db2 list db directory System Database Directory Number of entries in the directory = 1 Database 1 entry: Database alias = WZMDB Database name = WZMDB Local database directory = /home/wzm Database release level = a.00 Comment = Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alternate server port number = (III.) Operating instructions for the database ================================== ========================== (1.) Database creation [wzm@fedora ~]$ db2 "create database wzmdb" DB20000I The CREATE DATABASE command completed successfully. (2.) Connect to the database [wzm@fedora ~]$ db2 connect to wzmdb Database Connection Informati On Database server = DB2/LINUX 8.2.0 SQL authorization ID = WZM Local database alias = WZMDB () View table space db2 list tablespaces (show detail) db2pd -tablespaces -db <database name>

(3.) Table creation [wzm@fedora ~]$ db2 "create table wzmtb (id int,name varchar(30))" DB20000I The SQL command completed successfully. (4.) Display those tables in the database < Br>

[wzm@fedora ~]$ db2 list tables Table/View Schema Type Creation time ---------------------------- --- --------------- ----- -------------------------- WZMTB WZM T 2006-05-20-14.46.34.953560 1 record(s) selected. (5.) Add data to the table [wzm@fedora ~]$ db2 "insert into wzmtb values ​​(1,''wzm'') " DB20000I The SQL command completed successfully. (6.) Display the contents of the table [wzm@fedora ~]$ db2 "select * from wzmtb" ID NAME ----------- ----- ------------------------- 1 wzm 1 record(s) selected. (7.) Disconnect the database [wzm@fedora ~]$ Db2 disconnect wzmdb DB20000I The SQL DISCONNECT command Completed successfully.

(8.)Display which applications are currently connected to the database [wzm@fedora ~]$ db2 list application Auth Id Application Appl. Application Id DB # of Name Handle Name Agents ---- ---- -------------- ---------- ---------------------- -------- -------- ----- WZM db2bp 44 *LOCAL.wzm.060520074504 WZMDB 1

(9.) Stop of db2 [wzm@fedora ~ ]$ db2stop 05/20/2006 15:50:47 0 0 SQL1064N DB2STOP processing was successful. SQL1064N DB2STOP processing was successful.

(10.) Forced stop of db2zh-CNzh-CN

Copyright © Windows knowledge All Rights Reserved