4.讀資料庫管理程式配置
db2 get dbm cfg
5.寫資料庫管理程式配置
db2 update dbm cfg using 引數名 引數值
6.讀資料庫的配置
db2 connect to o_yd user db2 using pwd
db2 get db cfg for o_yd
7.寫資料庫的配置
db2 connect to o_yd user db2 using pwd
db2 update db cfg for o_yd using 引數名 引數值
8.關閉所有應用連線
9.備份資料庫
db2 backup db o_yd to d:
(db2 initialize tape on //./tape0)
(db2 rewind tape on //./tape0)
db2 backup db o_yd to //./tape0
10.恢復資料庫
db2 restore db o_yd from d: to d:
db2 restore db o_yd from //./tape0 to d:
11.繫結儲存過程
db2 connect to o_yd user db2 using pwd
db2 bind c:/dfplus.bnd
拷貝儲存過程到伺服器上的c:/sqllib/function目錄中
12.整理表
db2 connect to o_yd user db2 using pwd
db2 reorg table ydd
db2 runstats on table ydd with distribution and indexes all
13.匯出表資料
db2 export to c:/dftz.txt of
del
select * from dftz
db2 export to c:/dftz.ixf of ixf select * from dftz
14.匯入表資料
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)
15.執行乙個批處理檔案
db2 –tf 批處理檔名
(檔案中每一條命令用 ;結束)
16.自動生成批處理檔案
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
17.自動生成建表(檢視)語句
在伺服器上: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
18.其他命令
grant dbadm on database to user bb 19
select * from czyxx fetch first 1 rows only 20
db2look –d ylbx –u db2admin –w –asd –a –e –o a.txt
21. 顯示當前使用者所有表
list tables
22. 列出所有的系統表
list tables for system
23. 檢視表結構
db2 describe select * from user.tables
24. 檢視死鎖明細
db2 get snapshot for locks on yourdatdabasename
用df -k命令看看是不是有些檔案系統沒有空間了
db2
資料庫從aix
匯入nt:
先以db2的instance (for aix)login
然後執行:
db2look -d 資料庫名-e -c -o 輸出檔名此命令為匯出庫的結構,並生成乙個輸出檔名.sql的檔案
db2 connect to 資料庫名
db2move 資料庫名export
然後在win客戶端,先建上與aix同名的資料庫
ftp aix server
將前步操作匯出的所有檔案get過來。
在win平台下,進入db2命令視窗,轉到含匯出檔案的path
編輯 輸出檔名.sql,確保各tablespce名稱等一致
執行:db2 connect to 資料庫名
而後執行:db2 -tvf 輸出檔名.sql
編輯db2move.lst,保證instance的一致。
最後,執行db2move 資料庫名load
注:這種操作只能保證codepage一致時才能用,如果codepage不一致,要用load命令乙個個表的倒。
DB2常用命令
常用操作 db2 list db directory db2 connect to user using db2ilist 顯示當前例項名 db2 list tables 顯示當前例項下的所有表 db2 list tablespaces 顯示表空間 db2pd db tablespaces 檢視表空...
DB2常用命令
1 db2 list node directory 2 db2 list node directory show detail 3 db2 catalog tcpip node wsii remote 9.181.139.155 server 50000 4 db2 catalog database...
DB2常用命令
例項 clp 命令描述 db2start 啟動資料庫管理器例項。db2stop 停止資料庫管理器例項。get dbm cfg 返回資料庫管理器配置設定。get dbm cfg show detail 顯示資料庫管理器引數的當前值和延遲值 從 v8 起 1update dbm cfg using 將資...