db2inst@linux11:~$ db2ilist
db2inst db2inst@linux11:~$ db2 list database directory
System Database Directory Number of entries in the directory = 1 Database 1 entry: Database alias = SAMPLE Database name = SAMPLE Local database directory = /home/db2inst Database release level = d.00 Comment = Directory entry type = Indirect Catalog database partition number = 0 Alternate server hostname = Alternate server port number = db2inst@linux11:~$ db2 connect to sample SQL1032N No start database manager command was issued. SQLSTATE=57019 db2inst@linux11:~$ db2start SQL1063N DB2START processing was successful. db2inst@linux11:~$ db2 connect to sample Database Connection Information Database server = DB2/LINUX 9.7.1 SQL authorization ID = DB2INST Local database alias = SAMPLE db2inst@linux11:~$ db2 list tables
Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- ACT DB2INST T 2010-12-29-17.20.08.198182 ADEFUSR DB2INST S 2010-12-29-17.20.15.866736 CATALOG DB2INST T 2010-12-29-17.20.33.823019 CL_SCHED DB2INST T 2010-12-29-17.19.57.901308 CUSTOMER DB2INST T 2010-12-29-17.20.29.201829 DEPARTMENT DB2INST T 2010-12-29-17.19.58.760218 DEPT DB2INST A 2010-12-29-17.20.00.037330 EMP DB2INST A 2010-12-29-17.20.01.168002 EMPACT DB2INST A 2010-12-29-17.20.08.196197 EMPLOYEE DB2INST T 2010-12-29-17.20.00.038547 EMPMDC DB2INST T 2010-12-29-17.20.20.571620 EMPPROJACT DB2INST T 2010-12-29-17.20.07.657918 EMP_ACT DB2INST A 2010-12-29-17.20.08.197282 EMP_PHOTO DB2INST T 2010-12-29-17.20.01.169407 EMP_RESUME DB2INST T 2010-12-29-17.20.03.116023 INVENTORY DB2INST T 2010-12-29-17.20.28.001869 IN_TRAY DB2INST T 2010-12-29-17.20.09.357993 ORG DB2INST T 2010-12-29-17.20.09.906673 PRODUCT DB2INST T 2010-12-29-17.20.26.042111 PRODUCTSUPPLIER DB2INST T 2010-12-29-17.20.37.753741 PROJ DB2INST A 2010-12-29-17.20.06.518714 PROJACT DB2INST T 2010-12-29-17.20.06.520367 PROJECT DB2INST T 2010-12-29-17.20.05.422969 PURCHASEORDER DB2INST T 2010-12-29-17.20.30.877075 SALES DB2INST T 2010-12-29-17.20.11.053228 STAFF DB2INST T 2010-12-29-17.20.10.445646 STAFFG DB2INST T 2010-12-29-17.20.14.333883 SUPPLIERS DB2INST T 2010-12-29-17.20.36.052710 VACT DB2INST V 2010-12-29-17.20.11.739953 VASTRDE1 DB2INST V 2010-12-29-17.20.11.833058 VASTRDE2 DB2INST V 2010-12-29-17.20.11.838598 VDEPMG1 DB2INST V 2010-12-29-17.20.11.818672 VDEPT DB2INST V 2010-12-29-17.20.11.557304 VEMP DB2INST V 2010-12-29-17.20.11.733034 VEMPDPT1 DB2INST V 2010-12-29-17.20.11.828279 VEMPLP DB2INST V 2010-12-29-17.20.11.877433 VEMPPROJACT DB2INST V 2010-12-29-17.20.11.813495 VFORPLA DB2INST V 2010-12-29-17.20.11.859814 VHDEPT DB2INST V 2010-12-29-17.20.11.727739 VPHONE DB2INST V 2010-12-29-17.20.11.872415 VPROJ DB2INST V 2010-12-29-17.20.11.736679 VPROJACT DB2INST V 2010-12-29-17.20.11.790290 VPROJRE1 DB2INST V 2010-12-29-17.20.11.844475 VPSTRDE1 DB2INST V 2010-12-29-17.20.11.850540 VPSTRDE2 DB2INST V 2010-12-29-17.20.11.855591 VSTAFAC1 DB2INST V 2010-12-29-17.20.11.863893 VSTAFAC2 DB2INST V 2010-12-29-17.20.11.867994 47 record(s) selected. db2inst@linux11:~$ db2
(c) Copyright IBM Corporation 1993,2007 Command Line Processor for DB2 Client 9.7.1 You can issue database manager commands and SQL statements from the command prompt. For example: db2 => connect to sample db2 => bind sample.bnd For general help, type: ?. For command help, type: ? command, where command can be the first few keywords of a database manager command. For example: ? CATALOG DATABASE for help on the CATALOG DATABASE command ? CATALOG for help on all of the CATALOG commands. To exit db2 interactive mode, type QUIT at the command prompt. Outside interactive mode, all commands must be prefixed with 'db2'. To list the current command option settings, type LIST COMMAND OPTIONS. For more detailed help, refer to the Online Reference Manual. db2 => create table table1(c1 int,c2 int) DB20000I The SQL command completed successfully. db2 => select * from table1 C1 C2 ----------- ----------- 0 record(s) selected. db2 => quit
|
db2inst@linux11:~$ db2 attach to db2inst
Instance Attachment Information Instance server = DB2/LINUX 9.7.1 Authorization ID = DB2INST Local instance alias = DB2INST db2inst@linux11:~$ db2 connect to sample Database Connection Information Database server = DB2/LINUX 9.7.1 SQL authorization ID = DB2INST Local database alias = SAMPLE db2inst@linux11:~$ db2set -lr
DB2_OVERRIDE_BPF ...... DB2_STANDBY_ISO
db2inst@linux11:~$ db2set
DB2PROCESSORS=0 db2inst@linux11:~$ db2set -all
[i] DB2PROCESSORS=0 [g] DB2SYSTEM=linux11 [g] DB2INSTDEF=db2inst [g] DB2ADMINSERVER=dasusr db2inst@linux11:~$ db2 get instance
The current database manager instance is: db2inst db2inst@linux11:~$ db2 get dbm cfg|grep LOCK
Lock (DFT_MON_LOCK) = OFF db2inst@linux11:~$ db2 get db cfg|grep LOCK Max storage for lock list (4KB) (LOCKLIST) = 4096 Percent. of lock lists per application (MAXLOCKS) = 10 Lock timeout (sec) (LOCKTIMEOUT) = -1 Block non logged operations (BLOCKNONLOGGED) = NO Lock timeout events (MON_LOCKTIMEOUT) = NONE Deadlock events (MON_DEADLOCK) = WITHOUT_HIST Lock wait events (MON_LOCKWAIT) = NONE db2inst@linux11:~$ db2 get db cfg|grep DATABASE Size of database shared memory (4KB) (DATABASE_MEMORY) = AUTOMATIC(29088) db2inst@linux11:~$ db2 get db cfg|grep DATABASE Size of database shared memory (4KB) (DATABASE_MEMORY) = AUTOMATIC(29088) db2inst@linux11:~$ db2 update db cfg using LOCKLIST 8192
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. db2inst@linux11:~$ db2 get db cfg |grep LOCKLIST Max storage for lock list (4KB) (LOCKLIST) = 8192 db2inst@linux11:~$ db2 update db cfg using DATABASE_MEMORY 29089
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. db2inst@linux11:~$ db2 get db cfg|grep DATABASE Size of database shared memory (4KB) (DATABASE_MEMORY) = 29089 db2inst@linux11:~$ db2 update db cfg using DATABASE_MEMORY automatic DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. db2inst@linux11:~$ db2 get db cfg|grep DATABASE Size of database shared memory (4KB) (DATABASE_MEMORY) = AUTOMATIC(29089) db2inst@linux11:~$ db2 get dbm cfg show detail Database Manager Configuration Node type = Database Server with local and remote clients Description Parameter Current Value Delayed Value --------------------------------------------------------------------------------------------------------------- Database manager configuration release level = 0x0d00 CPU speed (millisec/instruction) (CPUSPEED) = 4.684080e-07 4.684080e-07 Max number of concurrently active databases (NUMDB) = 8 8 Federated Database System Support (FEDERATED) = NO NO Transaction processor monitor name (TP_MON_NAME) = |
db2inst@linux11:~$ db2 list applications
Auth Id Application Appl. Application Id DB # of Name Handle Name Agents -------- -------------- ---------- -------------------------------------------------------------- -------- ----- DB2INST db2bp 205 *LOCAL.db2inst.110103140837 SAMPLE 1 db2inst@linux11:~$ db2 force applications all DB20000I The FORCE APPLICATION command completed successfully. DB21024I This command is asynchronous and may not be effective immediately. db2inst@linux11:~$ db2 list applications SQL1611W No data was returned by Database System Monitor. db2inst@linux11:~$ db2 connect to sample Database Connection Information Database server = DB2/LINUX 9.7.1 SQL authorization ID = DB2INST Local database alias = SAMPLE db2inst@linux11:~$ db2 list applications Auth Id Application Appl. Application Id DB # of Name Handle Name Agents -------- -------------- ---------- -------------------------------------------------------------- -------- ----- DB2INST db2bp 235 *LOCAL.db2inst.110103141836 SAMPLE 1 db2inst@linux11:~$ db2 "force application(235)" DB20000I The FORCE APPLICATION command completed successfully. DB21024I This command is asynchronous and may not be effective immediately. |
db2inst@linux11:~$ db2set DB2COMM=TCPIP
db2inst@linux11:~$ db2set -all [i] DB2PROCESSORS=0 [i] DB2COMM=TCPIP [g] DB2SYSTEM=linux11 [g] DB2INSTDEF=db2inst [g] DB2ADMINSERVER=dasusr root@linux11:~# vi etc/services
root@linux11:/etc# cat /etc/services|grep db2
sample 61000/tcp # db2 sample database service root@linux11:/etc# su - db2inst
db2inst@linux11:~$ db2 update dbm cfg using svcename sample DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully. db2inst@linux11:~$ db2 get dbm cfg|grep SVCE
TCP/IP Service name (SVCENAME) = sample SSL service name (SSL_SVCENAME) = db2inst@linux11:~$ netstat -an|grep 61000
db2inst@linux11:~$ db2stop SQL1064N DB2STOP processing was successful. db2inst@linux11:~$ db2start SQL1063N DB2START processing was successful. db2inst@linux11:~$ netstat -an|grep 61000 tcp 0 0 0.0.0.0:61000 0.0.0.0:* LISTEN db2inst@linux11:~$ db2 get dbm cfg|grep DIS
Discovery mode (DISCOVER) = SEARCH Discover server instance (DISCOVER_INST) = ENABLE |
db2inst@linux11:~$ db2 get dbm cfg |grep GROUP SYSADM group name (SYSADM_GROUP) = DB2IADM SYSCTRL group name (SYSCTRL_GROUP) = SYSMAINT group name (SYSMAINT_GROUP) = SYSMON group name (SYSMON_GROUP) = Group Plugin (GROUP_PLUGIN) = db2inst@linux11:~$ id uid=500(db2inst) gid=600(db2iadm) groups=600(db2iadm),602(db2asgrp) |
root@linux11:/opt/softs/linux# ls eclipse install.bin root@linux11:/opt/softs/linux# ./install.bin Preparing to install... Extracting the installation resources from the installer archive... Configuring the installer for this system's environment... Launching installer... Graphical installers are not supported by the VM. The console mode will be used instead... Preparing CONSOLE Mode Installation... =============================================================================== Choose Locale... ---------------- 1- Deutsch ->2- English 3- Español 4- Français 5- Italiano 6- Português (Brasil) CHOOSE LOCALE BY NUMBER: =============================================================================== IBM Data Studio stand-alone (created with InstallAnywhere) ------------------------------------------------------------------------------- =============================================================================== Introduction ------------ InstallAnywhere will guide you through the installation of IBM Data Studio stand-alone. It is strongly recommended that you quit all programs before continuing with this installation. Respond to each prompt to proceed to the next step in the installation. If you want to change something on a previous step, type 'back'. You may cancel this installation at any time by typing 'quit'. PRESS <ENTER> TO CONTINUE: =============================================================================== International License Agreement for Non-Warranted Programs Part 1 - General Terms BY DOWNLOADING, INSTALLING, COPYING, ACCESSING, CLICKING ON AN "ACCEPT" BUTTON, OR OTHERWISE USING THE PROGRAM, LICENSEE AGREES TO THE TERMS OF THIS AGREEMENT. IF YOU ARE ACCEPTING THESE TERMS ON BEHALF OF LICENSEE, YOU REPRESENT AND WARRANT THAT YOU HAVE FULL AUTHORITY TO BIND LICENSEE TO THESE TERMS. IF YOU DO NOT AGREE TO THESE TERMS, * DO NOT DOWNLOAD, INSTALL, COPY, ACCESS, CLICK ON AN "ACCEPT" BUTTON, OR USE THE PROGRAM; AND * PROMPTLY RETURN THE UNUSED MEDIA AND DOCUMENTATION TO THE PARTY FROM WHOM IT WAS OBTAINED FOR A REFUND OF THE AMOUNT PAID. IF THE PROGRAM WAS DOWNLOADED, DESTROY ALL COPIES OF THE PROGRAM. 1. Definitions Press Enter to continue viewing the license agreement, or enter "1" to accept the agreement, "2" to decline it, "3" to print it, or "99" to go back to the previous screen.: 1 =============================================================================== Choose Install Folder --------------------- Where would you like to install? Default Install Folder: /opt/IBM/IBM Data Studio stand-alone ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT : =============================================================================== Pre-Installation Summary ------------------------ Please review the following information before continuing: Product Name: IBM Data Studio stand-alone Install Folder: /opt/IBM/IBM Data Studio stand-alone Disk Space Information (for Installation Target): Required: 302,542,667 bytes Available: 14,947,532,800 bytes PRESS <ENTER> TO CONTINUE: =============================================================================== Ready To Install ---------------- InstallAnywhere is now ready to install IBM Data Studio stand-alone onto your system at the following location: /opt/IBM/IBM Data Studio stand-alone PRESS <ENTER> TO INSTALL: =============================================================================== Installing... ------------- [==================|==================|==================|==================] [------------------|------------------|------------------|------------------] =============================================================================== Installation Complete --------------------- Congratulations! IBM Data Studio stand-alone has been successfully installed to: /opt/IBM/IBM Data Studio stand-alone PRESS <ENTER> TO EXIT THE INSTALLER: |
root@linux11:~# su - db2inst db2inst@linux11:~$ db2start SQL1063N DB2START processing was successful. db2inst@linux11:~$ db2 connect to sample Database Connection Information Database server = DB2/LINUX 9.7.1 SQL authorization ID = DB2INST Local database alias = SAMPLE db2inst@linux11:~$ id uid=500(db2inst) gid=600(db2iadm) groups=600(db2iadm),602(db2asgrp) db2inst@linux11:~$ db2 grant dbadm on database to user john DB20000I The SQL command completed successfully. db2inst@linux11:~$ db2 grant load on database to group db2asgrp DB20000I The SQL command completed successfully. db2inst@linux11:~$ db2 revoke load on database from group db2asgrp DB20000I The SQL command completed successfully. db2inst@linux11:~$ db2 list active databases Active Databases Database name = SAMPLE Applications connected currently = 1 Database path = /home/db2inst/db2inst/NODE0000/SQL00001/ |
db2inst@linux11:~$ db2 create schema dev
DB20000I The SQL command completed successfully. db2inst@linux11:~$ db2 "create table dev.test(id int)"
DB20000I The SQL command completed successfully. db2inst@linux11:~$ db2 "insert into dev.test values(100)" DB20000I The SQL command completed successfully. db2inst@linux11:~$ db2 "select * from dev.test" ID ----------- 100 1 record(s) selected. db2inst@linux11:~$ db2 describe table dev.test Data type Column Column name schema Data type name Length Scale Nulls ------------------------------- --------- ------------------- ---------- ----- ------ ID SYSIBM INTEGER 4 0 Yes 1 record(s) selected. db2inst@linux11:~$ db2 list tables for schema dev Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- TEST DEV T 2011-01-06-13.52.36.195314 1 record(s) selected. |
db2inst@linux11:~$ db2 grant select,update,delete,insert on table dev.test to user john with grant option DB20000I The SQL command completed successfully. |
10.授予隐式及间接特权:执行一些特定操作时获得授权时隐含的。例如:创建对象的用户被赋予CONTROL特权;被授予DBADM的被隐式授权BINDADD,CONNECT,CREATETAB,CREATE_NOT_FENCED和IMPLICIT_SCHEMA权限;用户创建数据库会获得DBADM,CONNECT,CREATETAB,BINDADD,IMPLICIT_SCHEMA,USERSPACE1上的USE OF TABLESPACE被赋予PUBLIC等。
安排作业
作业是通过IBM DB2 Task Center来实现的,包括创建和组织任务,管理任务流,安排任务,任务状态通知等。
db2inst@linux11:~$ db2 create bufferpool bp2 size 1000 pagesize 8k numblockpages 900 DB20000I The SQL command completed successfully. |
db2inst@linux11:~$ db2 list tables
Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- ACT DB2INST T 2010-12-29-17.20.08.198182 ... VSTAFAC2 DB2INST V 2010-12-29-17.20.11.867994
48 record(s) selected. db2inst@linux11:~$ db2 list tables for all Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- ACT DB2INST T 2010-12-29-17.20.08.198182 .... TEST DEV T 2011-01-06-13.52.36.195314
ATTRIBUTES SYSCAT V 2010-12-29-17.18.25.774427 ... CHECK_CONSTRAINTS SYSIBM V 2010-12-29-17.18.25.120022
... ADMINTABCOMPRESSINFO SYSIBMADM V 2010-12-29-17.18.50.352927
... DUAL SYSPUBLIC A 2010-12-29-17.18.25.383384
COLDIST SYSSTAT V 2010-12-29-17.18.30.148698 ... HMON_ATM_INFO SYSTOOLS T 2010-12-29-17.22.20.232579
HMON_COLLECTION SYSTOOLS T 2010-12-29-17.22.20.522058 POLICY SYSTOOLS T 2010-12-29-17.22.18.316991 445 record(s) selected. db2inst@linux11:~$ db2 list tables for system Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- ATTRIBUTES SYSCAT V 2010-12-29-17.18.25.774427 ... HMON_COLLECTION SYSTOOLS T 2010-12-29-17.22.20.522058 POLICY SYSTOOLS T 2010-12-29-17.22.18.316991 396 record(s) selected. db2inst@linux11:~$ db2 list tables for schema dev Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- TEST DEV T 2011-01-06-13.52.36.195314 1 record(s) selected. db2inst@linux11:~$ db2 describe table dev.test Data type Column Column name schema Data type name Length Scale Nulls ------------------------------- --------- ------------------- ---------- ----- ------ ID SYSIBM INTEGER 4 0 Yes 1 record(s) selected. |
多维聚合(MDC)
通常的,更大的盘区会减少I/O成本,因为每次读取了更多的数据;同时又减少了维块索引的数量,插入操作更快;因为盘区大,所以比小盘区更浪费磁盘空间。
表分区
创建一个分区表、将一个新的物理表添加到分区表中的两个语法示意:
表压缩和预压缩
启用表压缩的语法:
开始表压缩的语法:
先不压缩,看看压缩效果(估计空间节约):
XML列于XML索引
略
数据管理
额外列值索引
DB2的索引,可以包含额外的列值进行存储,例如:
集群索引将相同的键值存放于相同的页内,减少键值查找时所需的开销。集群索引只需在普通索引创建语句后加CLUSTER关键词:
信息约束
可以使用not enforced来不强制约束生效(类似disable constraint),可以使用enable query optimization来使优化器使用约束定义的信息。示例如下:
系统编目表
db2inst@linux11:~/sqllib/misc$ db2 connect to sample
Database Connection Information Database server = DB2/LINUX 9.7.1 SQL authorization ID = DB2INST Local database alias = SAMPLE db2inst@linux11:~/sqllib/misc$ db2 -tf EXPLAIN.DDL ******* IMPORTANT ********** USAGE: db2 -tf EXPLAIN.DDL ******* IMPORTANT ********** DB20000I The UPDATE COMMAND OPTIONS command completed successfully. DB20000I The SQL command completed successfully. db2inst@linux11:~/sqllib/misc$ db2 "explain all for select * from dev.test" DB20000I The SQL command completed successfully. |
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞0
添加新评论1 条评论
2013-03-18 10:40