導航:首頁 > 程序命令 > db2中命令

db2中命令

發布時間:2024-09-16 11:12:31

A. DB2資料庫在linux操作系統的指令有哪些

DB2資料庫命令簡介 1.啟動資料庫 DB2start 2.停止資料庫 DB2stop DB2資料庫在linux相關指令之3.連接資料庫 DB2 connect to o_yd user DB2 using pwd 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.關閉所有應用連接 DB2 force application all DB2 force application ID1,ID2,,,Idn MODE ASYNC (DB2 list application for db o_yd show detail) 9.備份資料庫 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 10.恢復資料庫 DB2 restore db o_yd from d: to d: DB2 restore db o_yd from \.tape0 to d: DB2資料庫在linux相關指令之11.綁定存儲過程 DB2 connect to o_yd user DB2 using pwd DB2 bind c:dfplus.bnd 拷貝存儲過程到伺服器上的C:sqllibfunction目錄中 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.自動生成批處理文件 建文本文件: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 17.自動生成建表(視圖)語句 在伺服器上:C:sqllibmisc目錄中 DB2 connect to o_yd user DB2 using pwd DB2look -d o_yd -u DB2 -e -p -c c:o_yd.txt DB2資料庫在linux相關指令之18.其他命令 grant dbadm on database to user bb 19select * from czyxx fetch first 1 rows only 20DB2look -d ylbx -u DB2admin -w -asd -a -e -o a.txt21. 顯示當前用戶所有表 list tables 22.列出所有的系統表 list tables for system 23.查看錶結構 DB2 describe select * from user.tables (實習編輯:HJ)

B. 在DB2命令行中什麼命令能查看資料庫所在實例

db2ilist可以查看系統上的所有實例,有一個環境變數可以設置默認啟動的實例。如果是在Lniux或UNIX系統,會存在一個實例用戶,用這個實例用戶連接的實例名與實例用戶名相同。

副本跟實例不是一個概念。一個副本可以理解為一個DB2資料庫產品的安裝,一個系統上可以安裝多個副本,主要是為了在同一個系統上使用多個DB2的版本,比如V8 和 V9。安裝DB2時如果系統里不存在一個叫DB2的實例,則會默認創建名為DB2的實例,如果已經存在,則會創建DB2_01,依此類推

C. 怎樣使用命令行執行DB2的SQL

一、准備工作
運行db2cmd或者db2cw打開DB2命令行處理器

進入SQL腳本存放目錄

用db2 connect to <dbname> user <username> using <password> 命令連接資料庫

用db2 set current schema <schema_name> 設置當前的SCHEMA,這個SCHEMA可以是未創建的,DB2會自動創建。
二、執行不同類型的SQL

1、在命令行執行簡單SQL命令

db2 <SQL語句內容>

2、在命令行執行SQL腳本文件

db2 -td; -cf <SQL腳本文件路徑> -l <輸出日誌文件路徑>

說明:-td; 指定語句結束標志。因為一般SQL都是以分號結尾,所以就寫成「-td;」。

-l <輸出日誌文件路徑> 是可選的。

3、在命令行執行DB2 存儲過程文件
db2 -td@ -f <SQL過程文件路徑> -l <輸出日誌文件路徑>

說明:-td@ 指定語句結束標志。因為一般SQL過程都是以@結尾,所以就寫成「-td@」。

-l <輸出日誌文件路徑> 是可選的。

D. 哪位高手知道DB2的常用命令是什麼哦麻煩說一下,謝謝啦

1、db2 connect to <資料庫名> user <用戶名> using <密碼> --連接資料庫
2、 db2 force application all --強迫所有應用斷開資料庫連接
3、db2 backup db db2name<資料庫名稱> --備份整個資料庫數據
db2 restore db <db2name> --還原資料庫
4、db2 list application --查看所有連接(需要連接到具體資料庫才能查看)

5、db2start --啟動資料庫 ,db2stop --停止資料庫
6、create database <資料庫名> using codeset utf-8 territory CN --創建資料庫使用utf-8編碼
7、db2 catalog 命令
db2 catalog tcpip node <接點名稱> remote <遠程資料庫地址> server <埠號> --把遠程資料庫映射到本地接點一般為50000
db2 catalog db <遠程資料庫名稱> as <接點名稱> at node PUB11 --遠程資料庫名稱到本地接點
db2 CONNECT TO <接點名稱> user <用戶名> using <密碼> --連接本地接點訪問遠程資料庫
8、資料庫導出
db2look -d <資料庫名> -u <用戶> -e -o <腳本名稱>.sql --導出資料庫的表結構,其中用戶空間一般為db2admin/db2inst1
db2look -d <資料庫名> -u <用戶> -t <表1> <表2> -e -o <腳本名稱>.sql --導出資料庫中表1和表2的表結構
db2move <資料庫名> export --導出資料庫數據
db2move <資料庫名> export -tn <表1>,<表2> --導出資料庫中表和表數據

9、資料庫導入
db2 -tvf <腳本名稱>.sql --把上述導出的表結構導入到資料庫表結構
db2move <資料庫名> load -lo replace --把上述「db2move <資料庫名> export 「導出的數據導入到資料庫中並把相同的數據替換掉 在實際使用過程中,如果用到db2自增主鍵,需要使用by default, 而不是always,功能是一樣的,但這樣在數據移植時候會很方便!
10、db2 connect reset 或 db2 terminate --斷開與資料庫的連接
11、db2set db2codepage=1208 --修改頁編碼為1208
12、db2 describe table <表名> --查看錶結構(比較常用)
13、db2 list tables --查看資料庫中所有表結構(常用)
list tables for system --列出所有系統表
14、db2 list tablespaces --列出表空間
15、fetch first 10 rows only --列出表中前10條數據
例如:select * from <表名> fetch first 10 rows only
16、coalesce(欄位名,轉換後的值) --對是null的欄位進行值轉換
value(欄位名,轉換後的值) --對是null的欄位進行值轉換
例如:select coalesce(id,1) from <表名> --對表中id如果為null轉換成1
select value(id,1) from 表日)
17、concatt(參數1,連接值) --把參數1加上連接值組成一個新值。
例如:concat('aa','b') --返回是aab

18、create alise admin.tb_biao on tb_biao 創建 同義詞
19、查詢系統時間「
select current timestamp from sysibm.sysmmy1;
這些裡面有網上的有我自己整理的,希望對你有幫助!

E. 在DB2資料庫中 有什麼命令可以查看當前有哪些資料庫

你好4. 查看系岩爛統資料庫目錄 db2 list database directory 5. 查看本地資料庫目錄 db2 list database directory on <盤符> 在本地數粗局漏據庫目錄中有而系統資料庫目錄中沒有的資料庫不能訪問,可以在控制中心中選中<資料庫>右鍵單擊選擇添加,然後輸入需要添加的資料庫名臘前稱或者點擊刷新按鈕選擇資料庫,加入資料庫後即可以訪問。

F. db2常用命令

操作資料庫命令

1、 啟動資料庫實例

#db2start

2、 停止資料庫實例

#db2stop

如果你不能停止資料庫由於激活的連接,在運行db2stop前執行db2 force application all就可以了 /db2stop force

3、 創建資料庫

#db2 create db [dbname]

4、 連接到資料庫

#db2 connect to [dbname] user[username] using [password]

5、 斷開資料庫連接

#db2 connect reset

操作數據表命令

1、 列出所有用戶表

#db2 list tables

2、列出所有系統表

#db2 list tables for system

3、列出所有表

#db2 list tables for all

4、 列出系統表

#db2 list tables for system

5、列出用戶表

#db2 list tables for user

6、 列出特定用戶表

#db2 list tables for schema[user]

閱讀全文

與db2中命令相關的資料

熱點內容
手機proxy伺服器地址 瀏覽:449
吉他清音壓縮 瀏覽:301
簡歷模板程序員 瀏覽:881
螺桿壓縮機虛標型號 瀏覽:953
idea開發項目伺服器ip地址 瀏覽:125
串口伺服器出現亂碼怎麼解決 瀏覽:950
命令按鈕的default 瀏覽:161
戰網如何登錄其他伺服器 瀏覽:990
中國銀行app如何關閉簡訊 瀏覽:493
nx120編程技巧 瀏覽:722
手機也能使用源碼公式 瀏覽:918
怎樣把壓縮的文件下載 瀏覽:334
pdf是哪的 瀏覽:27
群暉伺服器如何建立自己資料庫 瀏覽:868
win10怎麼查找伺服器地址 瀏覽:506
freepdfsplit 瀏覽:172
如何更改linux伺服器地址 瀏覽:221
編程求字元串abcdefh長度 瀏覽:312
座機時間伺服器地址 瀏覽:419
華康寶app是怎麼樣的 瀏覽:73