欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

安裝DB2

張軍 8557 0

1.1  下載安裝軟件

DB2v10.5.0.4_linuxx64_expc.tar

1.2  解壓安裝軟件

[root@localhost opt]# tar zxvf   DB2v10.5.0.4_linuxx64_expc.tar.gz

[root@localhost opt]# cd expc/

[root@localhost expc]# ll

total 52

drwxr-xr-x. 6 bin bin 4096 Aug 14  2014 db2

-r-xr-xr-x. 1 bin bin 5349 Aug 14  2014 db2ckupgrade

-r-xr-xr-x. 1 bin bin 5302 Aug 14  2014 db2_deinstall

-r-xr-xr-x. 1 bin bin 5172 Aug 14  2014 db2_install

-r-xr-xr-x. 1 bin bin 5136 Aug 14  2014 db2ls

-r-xr-xr-x. 1 bin bin 5154 Aug 14  2014 db2prereqcheck

-r-xr-xr-x. 1 bin bin 5154 Aug 14  2014 db2setup

 

1.3  執(zhí)行安裝腳本

[root@localhost expc]# ./db2setup

Requirement not matched for DB2 database   "Server" . Version: "10.5.0.4".

 

Summary of prerequisites that are not met   on the current system:

 

     DBT3514W  The db2prereqcheck   utility failed to find the following 32-bit library file:   "/lib/libpam.so*".

 

 

DBT3514W    The db2prereqcheck utility failed to find the following 32-bit library   file: "libstdc++.so.6".

 

 

DBI1190I    db2setup is preparing the DB2 Setup wizard which will guide

        you through the program setup process. Please wait.

1647305513(1).jpg

 

1.4        選擇Install a Product,點(diǎn)擊Install New

1647305529(1).jpg

1647305553(1).jpg

 

1.5        接受許可協(xié)議

1647305568(1).jpg

 

1.6        選擇Typical

1647305585(1).jpg

 

1.7        選擇Install DB2 Express

1647305601.jpg

 

1.8        選擇安裝目錄

1647305620(1).jpg

 

1.9        創(chuàng)建dasusr1用戶,密碼zhangjun

1647305634(1).jpg

 

1.10   創(chuàng)建DB2實(shí)例

1647305653(1).jpg

1647305669(1).jpg

1647305682(1).jpg

 

1.11   驗(yàn)證安裝信息

1647305697(1).jpg

Product to install:                       DB2 Express-C

Installation type:                       Typical

                                        

Previously Installed Components:       

                                       

Selected Components:                   

      Base client support                         

      Java support                             

      SQL procedures                         

      Base server support                        

      DB2 data source support                    

      DB2 LDAP support                       

      DB2 Instance Setup wizard                 

      Integrated Flash Copy Support          

      Communication support - TCP/IP            

      DB2 Update Service                      

      Sample database source                    

      First Steps                              

                                       

Languages:                             

      English                              

          All Products                       

                                       

Target directory:                              /opt/ibm/db2/V10.5

                                       

Space required:                              935 MB

                                       

New instances:                         

      Instance name:                            db2inst1

          Start instance on reboot:          Yes

          TCP/IP configuration:                

            Service name:                  db2c_db2inst1

            Port number:                   50000

          Instance user information:       

            User name:                    db2inst1

            Group name:                  db2iadm1

            Home directory:                /home/db2inst1

          Fenced user information:              

            User name:                    db2fenc1

            Group name:                  db2fadm1

            Home directory:                /home/db2fenc1

                                       

                                          

DB2 Administration server:             

      Instance user information:             

          User name:                        dasusr1

          Group name:                      dasadm1

          Home directory:                    /home/dasusr1

      SMTP server:                            localhost.localdomain

                                       

                                       

                                       

Contact specification:                 

      New contacts:                         

          Name:                                  db2inst1

          Instance:                          db2inst1

          E-mail address:                      db2inst1@localhost.localdomain

          E-mail address is for a pager:       No

                                        

                                       

Response file name:                          /root/db2expc.rsp

 

1.12   點(diǎn)擊Finsh開始安裝

1647305718(1).jpg

1647305730(1).jpg

 

1.13   安裝完成

1647305741(1).jpg

Post-install   steps

Required steps:

 

In order to start using DB2 you need to   logon using a valid user ID such as the DB2 instance owner's ID   "db2inst1".

 

You can connect to the DB2 instance   "db2inst1" using the port number "50000". Record it for   future reference.

 

Optional steps:

 

To validate your installation files,   instance, and database functionality, run the Validation Tool,   /opt/ibm/db2/V10.5/bin/db2val. For more information, see "db2val"   in the DB2 Information Center.

 

Open First Steps by running   "db2fs" using a valid user ID such as the DB2 instance owner's ID.   You will need to have DISPLAY set and a supported web browser in the path of   this user ID.

 

You should ensure that you have the   correct license entitlements for DB2 products and features installed on this   machine. Each DB2 product or feature comes with a license certificate file   (also referred to as a license key) that is distributed on an Activation CD,   which also includes instructions for applying the license file. If you   purchased a base DB2 product, as well as, separately priced features, you   might need to install more than one license certificate. The Activation CD   for your product or feature can be downloaded from Passport Advantage if it   is not part of the physical media pack you received from IBM. For more   information about licensing, search the Information Center   (http://publib.boulder.ibm.com/infocenter/db2luw/v10r5/index.jsp) using terms   such as "license compliance", "licensing" or   "db2licm".

 

To use your DB2 database product, you   must have a valid license. For information about obtaining and applying DB2   license files, see  http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.qb.server.doc/doc/c0061199.html.

 

Refer to "What's New"   http://publib.boulder.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.wn.doc/doc/c0052035.html   in the DB2 Information Center to learn about the new functions for DB2 10.5.

 

Verify that you have access to the DB2   Information Center based on the choices you made during this installation. If   you performed a typical or a compact installation, verify that you can access   the IBM Web site using the internet. If you performed a custom installation,   verify that you can access the DB2 Information Center location specified   during the installation.

 

Review the response file created at   /root/db2expc.rsp.  Additional   information about response file installation is available in the DB2   documentation under "Installing DB2 using a response file".

Log   file

Checking license agreement acceptance   :.......Success

Installing DB2 file sets :.......Success

Executing control tasks :.......Success

Updating global registry :.......Success

Starting DB2 Fault Monitor   :.......Success

Updating the db2ls and db2greg link   :.......Success

Registering DB2 licenses :.......Success

Setting default global profile registry   variables :.......Success

Creating the DB2 Administration Server   :.......Success

Initializing instance list   :.......Success

Configuring DB2 instances :.......Success  

Registering DB2 Update Service   :.......Success

Configuring the DB2 Administration Server   :.......Success

Updating global profile registry   :.......Success

Configuring health alert notifications   :.......Success

 

============================================================

 

DB2 Setup log file started at:  Sat Apr 04 06:44:42 AM 2015 PDT

============================================================

 

Operating system information: Linux   2.6.32-431.el6.x86_64.#1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64

                                       

Product to install:                       DB2 Express-C

Installation type:                       Typical

                                       

Previously Installed Components:       

                                       

Selected Components:                   

      Base client support                         

      Java support                             

      SQL procedures                         

      Base server support                        

      DB2 data source support                    

      DB2 LDAP support                       

      DB2 Instance Setup wizard                 

      Integrated Flash Copy Support          

      Communication support - TCP/IP            

      DB2 Update Service                      

      Sample database source                    

      First Steps                              

                                       

Languages:                             

      English                              

          All Products                       

                                       

Target directory:                              /opt/ibm/db2/V10.5

                                       

Space required:                              935 MB

                                       

New instances:                         

      Instance name:                            db2inst1

          Start instance on reboot:          Yes

          TCP/IP configuration:                

            Service name:                  db2c_db2inst1

            Port number:                   50000

          Instance user information:       

            User name:                    db2inst1

            Group name:                  db2iadm1

            Home directory:                /home/db2inst1

          Fenced user information:              

            User name:                    db2fenc1

            Group name:                  db2fadm1

            Home directory:                /home/db2fenc1

                                       

                                          

DB2 Administration server:             

      Instance user information:             

          User name:                        dasusr1

          Group name:                      dasadm1

          Home directory:                    /home/dasusr1

      SMTP server:                            localhost.localdomain

                                       

                                       

                                       

Contact specification:                 

      New contacts:                           

          Name:                                  db2inst1

          Instance:                          db2inst1

          E-mail address:                      db2inst1@localhost.localdomain

          E-mail address is for a pager:       No

                                          

                                       

Response file name:                          /root/db2expc.rsp

 

Checking license agreement acceptance   :.......Success

Installing: BASE_CLIENT_R

 

Installing: DB2_PRODUCT_MESSAGES_EN

 

Installing: BASE_CLIENT

 

Installing: JAVA_RUNTIME_SUPPORT

 

Installing: DB2_JAVA_HELP_EN

 

Installing: BASE_DB2_ENGINE_R

 

Installing: GSK

 

Installing: JAVA_SUPPORT

 

Installing: SQL_PROCEDURES

 

Installing: ICU_SUP

 

Installing: JAVA_COMMON_FILES

 

Installing: BASE_DB2_ENGINE

 

Installing: DB2_DATA_SOURCE_SUPPORT

 

Installing: LDAP_EXPLOITATION

 

Installing: INSTANCE_SETUP_SUPPORT

 

Installing: ACS

 

Installing: COMMUNICATION_SUPPORT_TCPIP

 

Installing: DB2_UPDATE_SERVICE

 

Installing: EDB

 

Installing: DB2_SAMPLE_DATABASE

 

Installing: CLPPLUS

 

Installing: FIRST_STEPS

 

Installing: EXPC_PRODUCT_SIGNATURE

 

Installing DB2 file sets :.......Success

Executing control tasks :.......Success

Updating global registry :.......Success

Starting DB2 Fault Monitor   :.......Success

Updating the db2ls and db2greg link   :.......Success

Registering DB2 licenses :.......Success

The value   "DB2_COMPATIBILITY_VECTOR=MYS" was set in the Profile Registry.

 

Setting default global profile registry   variables :.......Success

Creating the DB2 Administration Server   :.......Success

Initializing instance list   :.......Success

The instance "db2inst1" has   been created successfully.

 

The value   "SVCENAME=db2c_db2inst1" was set in the DBM CFG file for the

"db2inst1" instance.

 

The value "DB2AUTOSTART=YES"   was set in the Profile Registry for the "db2inst1"

instance.

 

Configuring DB2 instances :.......Success  

Registering DB2 Update Service   :.......Success

Configuring the DB2 Administration Server   :.......Success

Updating global profile registry   :.......Success

The contact "db2inst1" was   successfully added.

 

Configuring health alert notifications   :.......Success

 

1.14   操作數(shù)據(jù)庫(kù)

1.14.1    創(chuàng)建表空間

CREATE TABLESPACE exoatbs IN DATABASE   PARTITION GROUP IBMDEFAULTGROUP PAGESIZE 8K MANAGED BY SYSTEM USING   ('/home/exoa2/exoacontainer') EXTENTSIZE 32 PREFETCHSIZE 16    BUFFERPOOL IBMDEFAULT8K    OVERHEAD 24.10 TRANSFERRATE 0.90    DROPPED TABLE RECOVERY OFF;

CREATE TABLESPACE exoatbs16k    IN DATABASE PARTITION GROUP   IBMDEFAULTGROUP PAGESIZE 16K MANAGED BY SYSTEM USING   ('/home/exoa2/exoacontainer16k'     )   EXTENTSIZE 32    PREFETCHSIZE 16    BUFFERPOOL IBMDEFAULT16K    OVERHEAD 24.1 TRANSFERRATE 0.90    DROPPED TABLE RECOVERY OFF;

CREATE TABLESPACE exoatbs32k    IN DATABASE PARTITION GROUP   IBMDEFAULTGROUP PAGESIZE 32K MANAGED BY SYSTEM USING   ('/home/exoa2/exoacontainer32k'     )   EXTENTSIZE 32    PREFETCHSIZE 16    BUFFERPOOL IBMDEFAULT32K    OVERHEAD 24.1 TRANSFERRATE 0.90    DROPPED TABLE RECOVERY OFF;

GRANT USE OF TABLESPACE exoatbs TO   PUBLIC;

GRANT USE OF TABLESPACE exoatbs16k TO   PUBLIC;

GRANT USE OF TABLESPACE exoatbs32k TO   PUBLIC;

 

1.14.2    創(chuàng)建系統(tǒng)表空間

CREATE TEMPORARY TABLESPACE exoasystmp IN   DATABASE PARTITION GROUP IBMTEMPGROUP PAGESIZE 8K    MANAGED BY SYSTEM USING   ('/home/exoa2/exoasystmp'     )   EXTENTSIZE 32 PREFETCHSIZE 16 BUFFERPOOL IBMDEFAULT8K    OVERHEAD 24.10 TRANSFERRATE 0.90    DROPPED TABLE RECOVERY OFF;

CREATE TEMPORARY TABLESPACE exoasystmp16k   IN DATABASE PARTITION GROUP IBMTEMPGROUP PAGESIZE 16K MANAGED BY SYSTEM USING   ('/home/exoa2/exoasystmp16k'    )   EXTENTSIZE 32 PREFETCHSIZE 16 BUFFERPOOL IBMDEFAULT16K OVERHEAD 24.10   TRANSFERRATE 0.90    DROPPED TABLE   RECOVERY OFF;

CREATE TEMPORARY TABLESPACE exoasystmp32k   IN DATABASE PARTITION GROUP IBMTEMPGROUP PAGESIZE 32K MANAGED BY SYSTEM USING   ('/home/exoa2/exoasystmp32k') EXTENTSIZE 32 PREFETCHSIZE 16 BUFFERPOOL   IBMDEFAULT32K OVERHEAD 24.10 TRANSFERRATE 0.90    DROPPED TABLE RECOVERY OFF;

 

 

1.14.3    創(chuàng)建數(shù)據(jù)庫(kù)

create database <數(shù)據(jù)庫(kù)名> using codeset utf-8   territory CN    --創(chuàng)建數(shù)據(jù)庫(kù)使用utf-8編碼

db2 create db <數(shù)據(jù)庫(kù)名>

db2 create db test

 

1.14.4    創(chuàng)建表

create table zjt_tables as  (select * from tables) definition only;

create table zjt_views as (select * from   views) definition only;

create table yhdab (id varchar(10),   password varchar(10), ywlx varchar(10), kh varchar(10));

create table ywlbb (ywlbbh varchar(8),   ywmc varchar(60))

 

 

1.14.5    啟動(dòng)數(shù)據(jù)庫(kù)

  

db2start    --啟動(dòng)數(shù)據(jù)庫(kù)

 

1.14.6    停止數(shù)據(jù)庫(kù)

db2stop --停止數(shù)據(jù)庫(kù)

 

1.14.7    連接數(shù)據(jù)庫(kù)

db2 connect to <數(shù)據(jù)庫(kù)名>    --連接到本地?cái)?shù)據(jù)庫(kù)名      

db2 CONNECT TO <接點(diǎn)名稱> user <用戶名> using <密碼>                               --連接本地接點(diǎn)訪問(wèn)遠(yuǎn)程數(shù)據(jù)庫(kù)

db2 connect to <數(shù)據(jù)庫(kù)名> user <用戶名> using <密碼> --連接到遠(yuǎn)端數(shù)據(jù)庫(kù)

db2 connect to o_yd user db2 using pwd

db2 force application all      --強(qiáng)迫所有應(yīng)用斷開數(shù)據(jù)庫(kù)連接

1.14.8    讀數(shù)據(jù)庫(kù)管理程序配置

  db2 get dbm cfg

1.14.9    寫數(shù)據(jù)庫(kù)管理程序配置

  db2 update dbm cfg using 參數(shù)名 參數(shù)值

1.14.10讀數(shù)據(jù)庫(kù)的配置

  db2 connect to o_yd user db2 using pwd

  db2 get db cfg for o_yd

1.14.11寫數(shù)據(jù)庫(kù)的配置

  db2 connect to o_yd user db2 using pwd

  db2 update db cfg for o_yd using 參數(shù)名 參數(shù)值

1.14.12關(guān)閉所有應(yīng)用連接

db2 connect reset db2 terminate    --斷開與數(shù)據(jù)庫(kù)的連接

db2 force application all

db2 force application ID1,ID2,,,Idn MODE   ASYNC

(db2 list application for db o_yd show   detail)

 

1.14.13備份數(shù)據(jù)庫(kù)

db2 backup db db2name<數(shù)據(jù)庫(kù)名稱>  --備份整個(gè)數(shù)據(jù)庫(kù)數(shù)據(jù)

db2 force application all

db2 backup db o_yd to d:

(db2 initialize tape on \\.\tape0)

(db2 rewind tape on \\.\tape0)

db2 backup db o_yd to \\.\tape0

 

1.14.14恢復(fù)數(shù)據(jù)庫(kù)

db2 restore db <db2name>                     --還原數(shù)據(jù)庫(kù)

db2 restore db o_yd from d: to d:

db2 restore db o_yd from \\.\tape0 to d:

 

1.14.15綁定存儲(chǔ)過(guò)程

  db2 connect to o_yd user db2 using pwd

  db2 bind c:\dfplus.bnd

  拷貝存儲(chǔ)過(guò)程到服務(wù)器上的C:\sqllib\function目錄中

1.14.16整理表

  db2 connect to o_yd user db2 using pwd

  db2 reorg table ydd

  db2 runstats on table ydd with distribution and indexes all

1.14.17導(dǎo)出表數(shù)據(jù)

  db2 export to c:\dftz.txt of del select * from dftz

  db2 export to c:\dftz.ixf of ixf select * from dftz

1.14.18導(dǎo)入表數(shù)據(jù)

  import from c:\123.txt of del insert into ylbx.czyxx

  db2 import to c:\dftz.txt of del commitcount 5000 messages c:\dftz.msg insert into dftz

  db2 import to c:\dftz.ixf of ixf commitcount 5000 messages c:\dftz.msg insert into dftz

  db2 import to c:\dftz.ixf of ixf commitcount 5000 insert into dftz

  db2 import to c:\dftz.ixf of ixf commitcount 5000 insert_update into dftz

  db2 import to c:\dftz.ixf of ixf commitcount 5000 replace into dftz

  db2 import to c:\dftz.ixf of ixf commitcount 5000 create into dftz (IXF)

  db2 import to c:\dftz.ixf of ixf commitcount 5000 replace_create into dftz (IXF)

1.14.19執(zhí)行一個(gè)批處理文件

  db2 -tf 批處理文件名

  (文件中每一條命令用 ;結(jié)束)

1.14.20自動(dòng)生成批處理文件

  建文本文件:temp.sql

  select 'runstats on table DB2.' || tabname || '

  with distribution and detailed indexes all;'

  from syscat.tables where tabschema='DB2' and type='T';

  db2 -tf temp.sql>runstats.sql

1.14.21自動(dòng)生成建表(視圖)語(yǔ)句

  在服務(wù)器上:C:\sqllib\misc目錄中

  db2 connect to o_yd user db2 using pwd

  db2look -d o_yd -u db2 -e -p -c c:\o_yd.txt

1.14.22顯示當(dāng)前用戶所有表

  list tables

1.14.23列出所有的系統(tǒng)表

db2 list tables                            --查看數(shù)據(jù)庫(kù)中所有表結(jié)構(gòu)

list tables for system                  --列出所有系統(tǒng)表

 

1.14.24查看表結(jié)構(gòu)

db2 describe table <表名>       --查看表結(jié)構(gòu)

db2 describe select * from user.tables

 

1.14.25查看所有連接

db2 list application --查看所有連接(需要連接到具體數(shù)據(jù)庫(kù)才能查看)

 

1.14.26數(shù)據(jù)庫(kù)導(dǎo)出

db2look -d <數(shù)據(jù)庫(kù)名> -u <用戶> -e -o <腳本名稱>.sql        --導(dǎo)出數(shù)據(jù)庫(kù)的表結(jié)構(gòu),其中用戶空間一般為db2admin/db2inst1

 

db2look -d <數(shù)據(jù)庫(kù)名> -u <用戶> -t <1> <2>  -e -o <腳本名稱>.sql   --導(dǎo)出數(shù)據(jù)庫(kù)中表1和表2的表結(jié)構(gòu)

 

db2move <數(shù)據(jù)庫(kù)名> export              --導(dǎo)出數(shù)據(jù)庫(kù)數(shù)據(jù)

 

db2move <數(shù)據(jù)庫(kù)名> export -tn <1>,<2>       --導(dǎo)出數(shù)據(jù)庫(kù)中表和表數(shù)據(jù)

 

1.14.27數(shù)據(jù)庫(kù)導(dǎo)入

db2 -tvf    <腳本名稱>.sql       --把上述導(dǎo)出的表結(jié)構(gòu)導(dǎo)入到數(shù)據(jù)庫(kù)表結(jié)構(gòu)

db2move <數(shù)據(jù)庫(kù)名> load -lo replace   --把上述“db2move <數(shù)據(jù)庫(kù)名> export “導(dǎo)出的數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫(kù)中并把相同的數(shù)據(jù)替換掉  

在實(shí)際使用過(guò)程中,如果用到db2自增主鍵,需要使用by   default 而不是always,功能是一樣的,但這樣在數(shù)據(jù)移植時(shí)候會(huì)很方便!

 

1.14.28修改編碼

db2set db2codepage=1208        --修改頁(yè)編碼為1208

 

1.14.29查看表空間

db2 list tablespaces                  --列出表空間

 

1.14.30其他命令

1.14.30.1 db2 catalog  

db2 catalog tcpip node <接點(diǎn)名稱> remote <遠(yuǎn)程數(shù)據(jù)庫(kù)地址> server <端口號(hào)>  --把遠(yuǎn)程數(shù)據(jù)庫(kù)映射到本地接點(diǎn)一般為50000

db2 catalog db <遠(yuǎn)程數(shù)據(jù)庫(kù)名稱> as <接點(diǎn)名稱>  at node PUB11                       --遠(yuǎn)程數(shù)據(jù)庫(kù)名稱到本地接點(diǎn)

1.14.30.2 grant

grant dbadm on database to user bb

 

1.14.30.3 其它

select * from czyxx fetch first 1 rows   only

db2look -d ylbx -u db2admin -w -asd -a -e   -o a.txt

fetch first 10 rows  only     --列出表中前10條數(shù)據(jù)

select * from <表名> fetch first 10 rows only

 

1.14.31其它

15fetch first 10 rows    only   --列出表中前10條數(shù)據(jù)

 

例如:select *   from <表名> fetch   first 10 rows only

 

16coalesce(字段名,轉(zhuǎn)換后的值)       --對(duì)是null的字段進(jìn)行值轉(zhuǎn)換

 

例如:select   coalesce(id,1)  from <表名>    --對(duì)表中id如果為null轉(zhuǎn)換成1

 

17dayofweek(日期)     --計(jì)算出日期中是周幾(1是周日,2是周一.......7是周六)

 

         dayofweek_iso    --計(jì)算出日期中是周幾(1是周一.......7是周日)

       

 例如:dayofweek(date(2008-01-16))   --它會(huì)返回是4,代表星期三

            

             dayofweek_iso(date(2008-01-16))   --它會(huì)返回是3,代表星期三

 

18dayofyear(日期)   --一年中的第幾天,范圍在1-366范圍之內(nèi)

 

注意:參數(shù)中日期的格式是YYYY-MM-DD的形式,如果不是需要進(jìn)行轉(zhuǎn)換,否則函數(shù)不能使用

 

例如:日期是20080116必須要進(jìn)行轉(zhuǎn)換

 

dayofweek(concat(concat(concat(substr(openDate,1,4),'-'),concat(substr(openDate,5,2),'-')),substr(openDate,7,2)))   as week)

 

這樣格式正確的。

 

19concatt(參數(shù)1,連接值)       --把參數(shù)1加上連接值組成一個(gè)新值。

 

  例如: concat('aa','b')    --返回是aab

 

連接數(shù)據(jù)庫(kù):

 

      connect to [數(shù)據(jù)庫(kù)名] user [操作用戶名] using [密碼]

 

創(chuàng)建緩沖池(8K)

 

      create bufferpool ibmdefault8k IMMEDIATE    SIZE 5000 PAGESIZE 8 K ;

創(chuàng)建緩沖池(16K)(OA_DIVERTASKRECORD)

      create bufferpool ibmdefault16k IMMEDIATE    SIZE 5000 PAGESIZE 16 K ;

創(chuàng)建緩沖池(32K)(OA_TASK)

      create bufferpool ibmdefault32k IMMEDIATE    SIZE 5000 PAGESIZE 32 K ;

 

 

 

1. 啟動(dòng)實(shí)例(db2inst1):

 

db2start

 

2. 停止實(shí)例(db2inst1):

 

db2stop

 

3. 列出所有實(shí)例(db2inst1)

 

db2ilist

 

5.列出當(dāng)前實(shí)例:

 

db2 get instance

 

4. 察看示例配置文件:

 

db2 get dbm cfg|more

 

5. 更新數(shù)據(jù)庫(kù)管理器參數(shù)信息:

 

db2 update dbm cfg using para_name   para_value

 

 

7. 察看數(shù)據(jù)庫(kù)配置參數(shù)信息

 

db2 get db cfg for test|more

 

8. 更新數(shù)據(jù)庫(kù)參數(shù)配置信息

 

db2 update db cfg for test using   para_name para_value

 

10.刪除數(shù)據(jù)庫(kù):

 

db2 drop db test

 

11.連接數(shù)據(jù)庫(kù)

 

db2 connect to test

 

12.列出所有表空間的詳細(xì)信息。

 

db2 list tablespaces show detail

 

13.查詢數(shù)據(jù):

 

db2 select * from tb1

 

14.刪除數(shù)據(jù):

 

db2 delete from tb1 where id=1

 

15.創(chuàng)建索引:

 

db2 create index idx1 on tb1(id);

 

16.創(chuàng)建視圖:

 

db2 create view view1 as select id from   tb1

 

17.查詢視圖:

 

db2 select * from view1

 

18.節(jié)點(diǎn)編目

 

db2 catalog tcp node node_name remote   server_ip server server_port

 

19.察看端口號(hào)

 

db2 get dbm cfg|grep SVCENAME

 

20.測(cè)試節(jié)點(diǎn)的附接

 

db2 attach to node_name

 

21.察看本地節(jié)點(diǎn)

 

db2 list node direcotry

 

22.節(jié)點(diǎn)反編目

 

db2 uncatalog node node_name

 

23.數(shù)據(jù)庫(kù)編目

 

db2 catalog db db_name as db_alias at   node node_name

 

24.察看數(shù)據(jù)庫(kù)的編目

 

db2 list db directory

 

25.連接數(shù)據(jù)庫(kù)

 

db2 connect to db_alias user user_name   using user_password

 

26.數(shù)據(jù)庫(kù)反編目

 

db2 uncatalog db db_alias

 

27.導(dǎo)出數(shù)據(jù)

 

db2 export to myfile of ixf messages msg   select * from tb1

 

28.導(dǎo)入數(shù)據(jù)

 

db2 import from myfile of ixf messages   msg replace into tb1

 

29.導(dǎo)出數(shù)據(jù)庫(kù)的所有表數(shù)據(jù)

 

db2move test export

 

30.生成數(shù)據(jù)庫(kù)的定義

 

db2look -d db_alias -a -e -m -l -x -f -o   db2look.sql

 

31.創(chuàng)建數(shù)據(jù)庫(kù)

 

db2 create db test1

 

32.生成定義

 

db2 -tvf db2look.sql

 

33.導(dǎo)入數(shù)據(jù)庫(kù)所有的數(shù)據(jù)

 

db2move db_alias import

 

34.重組檢查

 

db2 reorgchk

 

35.重組表tb1

 

db2 reorg table tb1

 

36.更新統(tǒng)計(jì)信息

 

db2 runstats on table tb1

 

37.備份數(shù)據(jù)庫(kù)test

 

db2 backup db test

 

38.恢復(fù)數(shù)據(jù)庫(kù)test

 

db2 restore db test

 

399\.列出容器的信息

 

db2 list tablespace containers for tbs_id   show detail

 

40.創(chuàng)建表:

 

db2 ceate table tb1(id integer not   null,name char(10))

 

41.列出所有表

 

db2 list tables

 

42.插入數(shù)據(jù):

 

db2 insert into tb1 values(1,’sam’);

 

db2 insert into tb2 values(2,’smitty’);

 

. 建立數(shù)據(jù)庫(kù)DB2_GCB

 

CREATE DATABASE DB2_GCB ON G: ALIAS   DB2_GCB

 

USING CODESET GBK TERRITORY CN COLLATE   USING SYSTEM DFT_EXTENT_SZ 32

 

2. 連接數(shù)據(jù)庫(kù)

 

connect to sample1 user db2admin using   8301206

 

3. 建立別名

 

create alias db2admin.tables for   sysstat.tables;

 

CREATE ALIAS DB2ADMIN.VIEWS FOR   SYSCAT.VIEWS

 

create alias db2admin.columns for   syscat.columns;

 

create alias guest.columns for   syscat.columns;

 

 

5. 插入記錄

 

insert into zjt_tables select * from   tables;

 

insert into zjt_views select * from   views;

 

6. 建立視圖

 

create view V_zjt_tables as select   tabschema,tabname from zjt_tables;

 

7. 建立觸發(fā)器

 

CREATE TRIGGER zjt_tables_del

 

AFTER DELETE ON zjt_tables

 

REFERENCING OLD AS O

 

FOR EACH ROW MODE DB2SQL

 

Insert into zjt_tables1   values(substr(o.tabschema,1,8),substr(o.tabname,1,10))

 

8. 建立唯一性索引

 

CREATE UNIQUE INDEX I_ztables_tabname

 

[size=3]ON zjt_tables(tabname);

 

9. 查看表

 

select tabname from tables

 

where tabname='ZJT_TABLES';

 

10. 查看列

 

select SUBSTR(COLNAME,1,20) as 列名,TYPENAME as 類型,LENGTH as 長(zhǎng)度

 

from columns

 

where tabname='ZJT_TABLES';

 

11. 查看表結(jié)構(gòu)

 

db2 describe table user1.department

 

db2 describe select * from user.tables

 

12. 查看表的索引

 

db2 describe indexes for table   user1.department

 

13. 查看視圖

 

select viewname from views

 

where viewname='V_ZJT_TABLES';

 

14. 查看索引

 

select indname from indexes

 

where indname='I_ZTABLES_TABNAME';

 

15. 查看存貯過(guò)程

 

SELECT   SUBSTR(PROCSCHEMA,1,15),SUBSTR(PROCNAME,1,15)

 

FROM SYSCAT.PROCEDURES;

 

16. 類型轉(zhuǎn)換(cast)

 

ip datatype:varchar

 

select cast(ip as integer)+50 from   log_comm_failed

 

17. 重新連接

 

connect reset

 

18. 中斷數(shù)據(jù)庫(kù)連接

 

disconnect db2_gcb

 

19. view application

 

LIST APPLICATION;

 

20. kill application

 

FORCE APPLICATION(0);

 

db2 force applications all (強(qiáng)迫所有應(yīng)用程序從數(shù)據(jù)庫(kù)斷開)

 

21. lock table

 

lock table test in exclusive mode

 

22. 共享

 

lock table test in share mode

 

23. 顯示當(dāng)前用戶所有表

 

list tables

 

24. 列出所有的系統(tǒng)表

 

list tables for system

 

25. 顯示當(dāng)前活動(dòng)數(shù)據(jù)庫(kù)

 

list active databases

 

26. 查看命令選項(xiàng)

 

list command options

 

27. 系統(tǒng)數(shù)據(jù)庫(kù)目錄

 

LIST DATABASE DIRECTORY

 

28. 表空間

 

list tablespaces

 

29. 表空間容器

 

LIST TABLESPACE CONTAINERS FOR

 

Example: LIST TABLESPACE CONTAINERS FOR 1  

 

30. 顯示用戶數(shù)據(jù)庫(kù)的存取權(quán)限

 

GET AUTHORIZATIONS

 

31. 啟動(dòng)實(shí)例

 

DB2START

 

32. 停止實(shí)例

 

db2stop

 

33. 表或視圖特權(quán)

 

grant select,delete,insert,update on   tables to user

 

grant all on tables to user WITH GRANT   OPTION

 

34. 程序包特權(quán)

 

GRANT EXECUTE

 

ON PACKAGE PACKAGE-name

 

TO PUBLIC

 

35. 模式特權(quán)

 

GRANT CREATEIN ON SCHEMA SCHEMA-name TO   USER

 

36. 數(shù)據(jù)庫(kù)特權(quán)

 

grant connect,createtab,dbadm on database   to user

 

37. 索引特權(quán)

 

grant control on index index-name to user  

 

38. 信息幫助 (? XXXnnnnn )

 

:? SQL30081  

 

39. SQL 幫助(說(shuō)明 SQL 語(yǔ)句的語(yǔ)法)

 

help statement

 

例如,help   SELECT

 

40. SQLSTATE 幫助(說(shuō)明 SQL 的狀態(tài)和類別代碼)

 

? sqlstate ? class-code

 

41. 更改與"管理服務(wù)器"相關(guān)的口令

 

db2admin setid username password

 

42. 創(chuàng)建 SAMPLE 數(shù)據(jù)庫(kù)

 

db2sampl

 

db2sampl F:(指定安裝盤)

 

43. 使用操作系統(tǒng)命令

 

! dir

 

44. 轉(zhuǎn)換數(shù)據(jù)類型 (cast)

 

SELECT EMPNO, CAST(RESUME AS   VARCHAR(370))

 

FROM EMP_RESUME

 

WHERE RESUME_FORMAT = 'ascii'

 

45. UDF

 

要運(yùn)行 DB2 Java   存儲(chǔ)過(guò)程或 UDF,還需要更新服務(wù)器上的 DB2 數(shù)據(jù)庫(kù)管理程序配置,以包括在該機(jī)器上安裝 JDK 的路徑

 

db2 update dbm cfg using JDK11_PATH   d:sqllibjavajdk

 

TERMINATE

 

update dbm cfg using SPM_NAME sample

 

46. 檢查 DB2 數(shù)據(jù)庫(kù)管理程序配置

 

db2 get dbm cfg

 

47. 檢索具有特權(quán)的所有授權(quán)名

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'DATABASE' FROM SYSCAT.DBAUTH

 

UNION

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'TABLE ' FROM SYSCAT.TABAUTH

 

UNION

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'PACKAGE ' FROM SYSCAT.PACKAGEAUTH

 

UNION

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'INDEX ' FROM SYSCAT.INDEXAUTH

 

UNION

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'COLUMN ' FROM SYSCAT.COLAUTH

 

UNION

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'SCHEMA ' FROM SYSCAT.SCHEMAAUTH

 

UNION

 

SELECT DISTINCT GRANTEE, GRANTEETYPE,   'SERVER ' FROM SYSCAT.PASSTHRUAUTH

 

ORDER BY GRANTEE, GRANTEETYPE, 3

 

 

 

48. 修改表結(jié)構(gòu)

 

alter table yhdab ALTER kh SET DATA TYPE   varchar(13);

 

alter table yhdab ALTER ID SET DATA TYPE   varchar(13);

 

alter table lst_bsi alter bsi_money set   data type int;

 

insert into yhdab values

 

('20000300001','123456','user01','20000300001'),  

 

('20000300002','123456','user02','20000300002');  

 

49. 業(yè)務(wù)類型說(shuō)明

 

insert into ywlbb values

 

('user01','業(yè)務(wù)申請(qǐng)'),

 

('user02','業(yè)務(wù)撤消'),

 

('user03','費(fèi)用查詢'),

 

('user04','費(fèi)用自繳'),

 

('user05','費(fèi)用預(yù)存'),

 

('user06','密碼修改'),

 

('user07','發(fā)票打印'),

 

('gl01','改用戶基本信息'),

 

('gl02','更改支付信息'),

 

('gl03','日統(tǒng)計(jì)功能'),

 

('gl04','沖帳功能'),

 

('gl05','對(duì)帳功能'),

 

('gl06','計(jì)費(fèi)功能'),

 

('gl07','綜合統(tǒng)計(jì)')

 

備份數(shù)據(jù)庫(kù):

CONNECT TO EXOA;

QUIESCE DATABASE IMMEDIATE FORCE   CONNECTIONS;

CONNECT RESET;

BACKUP DATABASE EXOA TO   "/home/exoa2/db2bak/" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1   WITHOUT PROMPTING;

CONNECT TO EXOA;

UNQUIESCE DATABASE;

CONNECT RESET;

 

以下是小弟在使用db2move中的一些經(jīng)驗(yàn),希望對(duì)大家有所幫助。

 

db2       connect     to    YOURDB    

連接數(shù)據(jù)庫(kù)

 

db2look -d    YOURDB      -a -e -x -o creatab.sql

導(dǎo)出建庫(kù)表的SQL

 

db2move     YOURDB      export

db2move將數(shù)據(jù)備份出來(lái)

 

vi       creatab.sql

如要導(dǎo)入的數(shù)據(jù)庫(kù)名與原數(shù)據(jù)庫(kù)不同,要修改creatab.sqlCONNECT 項(xiàng)

如相同則不用更改

 

db2move      NEWDB    load

將數(shù)據(jù)導(dǎo)入新庫(kù)中

 

在導(dǎo)入中可能因?yàn)榉N種原因發(fā)生中斷,會(huì)使數(shù)據(jù)庫(kù)暫掛

db2        list tablespaces     show     detail

如:

          詳細(xì)說(shuō)明:

         裝入暫掛

總頁(yè)數(shù)                            = 1652

可用頁(yè)數(shù)                          = 1652

已用頁(yè)數(shù)                           = 1652

空閑頁(yè)數(shù)                           = 不適用

高水位標(biāo)記(頁(yè))                   = 不適用

頁(yè)大小(字節(jié))                     = 4096

盤區(qū)大小(頁(yè))                     = 32

預(yù)讀取大小(頁(yè))                   = 32

容器數(shù)                             = 1

狀態(tài)更改表空間標(biāo)識(shí)                      = 2

狀態(tài)更改對(duì)象標(biāo)識(shí)                        = 59

 

db2 select tabname,tableid from   syscat.tables where tableid=59

查看是哪張表掛起

 

表名知道后到db2move.lst(db2move    YOURDB      export的目錄中)中找到相應(yīng)的.ixf文件

db2 load from tab11.ixf of ixf terminate   into db2admin.xxxxxxxxx

tab11.ixf對(duì)應(yīng)的是xxxxxxxxx

 

數(shù)據(jù)庫(kù)會(huì)恢復(fù)正常,可再用db2   list tablespaces show detail查看

 

 

 

30.不能通過(guò)GRANT授權(quán)的權(quán)限有哪種?

 

SYSAM

 

SYSCTRL

 

SYSMAINT

 

要更該述權(quán)限必須修改數(shù)據(jù)庫(kù)管理器配置參數(shù)

 

31.表的類型有哪些?

 

永久表(基表)

 

臨時(shí)表(說(shuō)明表)

 

臨時(shí)表(派生表)

 

32.如何知道一個(gè)用戶有多少表?

 

SELECT*FROMSYSIBM.SYSTABLESWHERECREATOR='USER'  

 

33.如何知道用戶下的函數(shù)?

 

select*fromIWH.USERFUNCTION

 

select*fromsysibm.SYSFUNCTIONS

 

34.如何知道用戶下的VIEW數(shù)?

 

select*fromsysibm.sysviewsWHERECREATOR='USER'  

 

35.如何知道當(dāng)前DB2的版本?

 

select*fromsysibm.sysvERSIONS

 

36.如何知道用戶下的TRIGGER數(shù)?

 

select*fromsysibm.SYSTRIGGERSWHERESCHEMA='USER'  

 

37.如何知道TABLESPACE的狀況?

 

select*fromsysibm.SYSTABLESPACES

 

38.如何知道SEQUENCE的狀況?

 

select*fromsysibm.SYSSEQUENCES

 

39.如何知道SCHEMA的狀況?

 

select*fromsysibm.SYSSCHEMATA

 

40.如何知道INDEX的狀況?

 

select*fromsysibm.SYSINDEXES

 

41.如何知道表的字段的狀況?

 

select*fromsysibm.SYSCOLUMNSWHERETBNAME='AAAA'  

 

42.如何知道DB2的數(shù)據(jù)類型?

 

select*fromsysibm.SYSDATATYPES

 

43.如何知道BUFFERPOOLS狀況?

 

select*fromsysibm.SYSBUFFERPOOLS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 日韩欧美亚洲一区 | 激情视频免费在线观看 | 欧美成人一级片 | 性 毛片| 乱码中文字幕人成在线 | 国产成人精品免高潮在线观看 | 精品的一区二区三区 | 天天干天天夜 | 一区二区三区视频在线播放 | 国产综合久久久久影院 | 精品免费国产一区二区三区 | 久久久国产视频 | 精品午夜寂寞影院在线观看 | 成人免费视频网站在线观看 | 91不卡在线 | 26uuu.mobi| 波多野吉衣一区二区三区四区 | 奇米影视第四色在线 | 久久久久亚洲精品 | 激情成人综合网 | 国产精品手机在线观看 | 久久久久久免费播放一级毛片 | www.91在线| 三级毛片黄色 | 国产一区二区三区高清 | 国产精品污污视频 | 中文字幕亚洲精品 | 日本在线视频www鲁啊鲁 | 新97人人模人人爽人人喊 | 精品免费国产一区二区三区四区 | 国产精品人妻无码免费久久一 | 国产精品极品美女在线观看免费 | 国产成人精品福利色多多 | 日韩欧美视频一区二区三区 | 狠狠干在线| 精品一二三区 | 久久日本精品国产精品白 | 成人免费视频网站 | 欧美区日韩区 | 免费视频99 | 日本大片久久久高清免费看 |