導航:首頁 > 程序命令 > linux命令行連接db2

linux命令行連接db2

發布時間:2025-03-07 07:00:00

『壹』 怎麼在linux上咱裝DB2

我網上復制來的,可以稍微看下,其實DB2也有安裝腳本的

安裝DB2
DB2的安裝可以算是再各個資料庫裡面最簡單的了。除了sqlite。
下載安裝包,解壓
[root@Enterprise tmp]# tar xvf DB2_V82_PE_LNX_32_NLV.tar
解開以後的文件都被放置在當前目錄下的pe文件夾中。
開始安裝:
[root@Enterprise tmp]# cd pe
[root@Enterprise pe]# ls
db2 db2_deinstall db2_install db2setup doc
[root@Enterprise pe]# ./db2_install
Specify one or more of the following keywords,
separated by spaces, to install DB2 procts.

選擇自己要安裝的產品,輸入名字後回車。等待安裝完成。
我們現在需要做的是,對資料庫的初始化工作。包括安裝授權文件和創建一個實例並運行它。
首先,我們安裝授權文件。
不安裝授權文件的話,則是評估版,九十天後就要過期。授權文件,在安裝包已經有了。我們用下面的命令安裝它:
[root@Enterprise pe]# /opt/IBM/db2/V8.2/adm/db2licm -a /tmp/pe/db2/lic
ense/db2pe.lic
如果沒有db2pe.lic 文件。可以去網上找找。
我們需要創建一個用戶。
[root@Enterprise pe]# useradd db2inst1
[root@Enterprise pe]# passwd db2inst1

開始創建實例:
[root@Enterprise pe]# /opt/IBM/db2/V8.2/instance/db2icrt -u db2inst1 db2inst1
這樣,我們就創建了一個實例db2ins1。

[root@Enterprise pe]# su db2inst1
[db2inst1@Enterprise pe]$ db2start
07/26/2007 16:45:10 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.

這樣我們資料庫就啟動成功。
[db2inst1@Enterprise pe]$ db2
(c) Copyright IBM Corporation 1993,2002
Command Line Processor for DB2 SDK 8.2.0
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 =>

創建一個最簡單的資料庫
db2 => create database testdb
DB20000I The CREATE DATABASE command completed successfully.

查看本instance下有哪些database
db2 => list database directory
System Database Directory
Number of entries in the directory = 2
Database 1 entry:
Database alias = TESTDB
Database name = TESTDB
Local database directory = /home/db2inst1
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = OMNIDB
Database name = OMNIDB
Local database directory = /home/db2inst1/data
Database release level = a.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

『貳』 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)

『叄』 linux怎麼連接linux下的db2

linux下安裝DB2的詳細步驟 第一步:檢查程序包及其版本 www.2cto.com 2 compat-libstdc++-7.3-2.96.118.i386.rpm 在linux的安裝盤上,使用rpm -i compat-libstdc++-7.3-2.96.118.i386.rpm 安裝即可第二步:配置 Linux 內核參數 /etc/sysctl.conf文件,添加內核參數2 kernel.msgmni =10242 kernel.sem = 250 256000 32 1024 使更改激活:sysctl –p第三步:安裝 sh db2_install 按照提示做第四步:創建用戶2 /usr/sbin/groupadd db2iadm12 /usr/sbin/groupadd db2fadm12 /usr/sbin/useradd –m -g db2iadm1 –d /home/db2inst1 db2inst12 /usr/sbin/useradd –m -g db2fadm1 –d /home/db2fenc1 db2fenc1第五步:創建實例2 /opt/IBM/db2/V8.1/instance/db2icrt –a server –u db2fenc1 db2inst1第六步:產品許可證2 /opt/IBM/db2/V8.1/adm/db2licm -a /mnt/cdrom/db2/license/db2pe.lic第七步:允許SMS的多頁分配 /opt/IBM/db2/V8.1/cfg/db2ln第八步:添加DB2埠 SU - root vi /etc/services 加入下面一行 db2inst1 50000/tcp第九步:DB2 配置 su – db2inst1 db2set DB2_EXTENDED_OPTIMIZATION=ON db2set DB2_DISABLE_FLUSH_LOG=ON db2set AUTOSTART=YES db2set DB2_STRIPED_CONTAINERS=ON db2set DB2_HASH_JOIN=Y db2set DB2COMM=tcpip db2set DB2_PARALLEL_IO=* db2set DB2CODEPAGE=819 #Update dbm cfgdb2 update dbm cfg using SVCENAME db2inst1db2 update dbm cfg using INDEXREC ACCESS第十步:運行DB2 www.2cto.com db2start第十一步:創建庫 db2 "CREATE DATABASE atmv1 ALIAS feelview USING CODESET ISO8859-1(UTF-8) TERRITORY CN"以後就可以創建表和對表操作了,如 db2 "select * from tbl"

『肆』 linux系統下 重啟db2資料庫

我用的CentOS系統,內核是Linux。 進入圖形界面後,在桌面上右鍵點擊「創建新終端」

1.在命令行界面中用如下語句切換到db2inst1賬戶中:
su - db2inst1

注意,命令要小寫,中間的減號是半形的。其中db2inst1賬戶(同時也是實例、進程)是在安裝DB2過程中創建的一個默認賬戶,相當於Windows中的那個DB2實例,要想執行各種db2的命令,需要在這個賬戶下操作;

2.在該賬戶下,可以打開控制中心,也可以進入到命令行處理器。進入命令行處理器的方法很簡單,直接用db2命令,然後回車即可;

3.打開控制中心稍微有點麻煩,需要在桌面上另外打開一個命令行窗口,在其中輸入:
xhost local:db2

然後在db2inst1賬戶所在的窗口中,輸入命令:
db2cc &
就可以打開控制中心。
4.現在可以查看當前實例
db2ilist
如果需要創建表,則需要打開資料庫管理服務,輸入命令:
su - db2inst1
db2start //啟動db2工作實例
db2stop //停止db2實例
db2set -all //查看db2所有注冊表變數

在變數列表中有一個db2管理用戶:DB2ADMINSERVER=XXXXX
只有切換到管理用戶才可以創建表 su - XXXXX
然後,輸入命令: db2admin start 啟動管理實例

說明:
在Linux環境下,一個用戶對應一個實例,創建資料庫必須在實例下創建,因此切換到用戶即可切換到實例。命令如下:

su - db2inst1
db2 get instance

『伍』 linux下如何連接db2資料庫命令

在 linux 系統上連接 db2 資料庫,請使用命令行工具 db2 connect。具體步驟包括:打開 linux 終端。輸入命令:db2 connect to user using ,其中 、 和 分別表示要連接的資料庫名稱、用戶名和密碼。按回車鍵,成功連接後會顯示連接信息。
在 Linux 下連接 DB2 資料庫的命令
在 Linux 系統上連接 DB2 資料庫需要使用命令行工具 db2 connect。
具體步驟:
打開 Linux 終端。輸入以下命令:
db2 connect to user using
其中:
是要連接的資料庫名稱。 是具有資料庫訪問許可權的用戶名。 是該用戶的密碼。
例如:要連接到名為 "test" 的資料庫,用戶名為 "user1",密碼為 "password1",則命令如下:
db2 connect to test user user1 using password1
按回車鍵。如果連接成功,將顯示以下消息:
Database Connection InformationDatabase server
= DB2/LINUXX8664 11.5.7.0SQL authorization ID = USER1Local database alias = TEST
現在,您已經成功連接到 DB2 資料庫。您可以輸入 SQL 語句來執行查詢、更新和管理數據。
提示:
確保您具有對要連接的資料庫的訪問許可權。如果連接失敗,請檢查用戶名和密碼是否正確,以及資料庫是否正在運行。可以使用 db2 help connect 命令獲取有關此命令的更多信息。

『陸』 在linux下如何使用命令創建DB2的實例哦.....db2icrt –u 後面的參數硬是不懂.

1. 創建一個用戶,比如用戶名是 db2inst1 用戶的home路徑是 /home/db2inst1
2. 再創建一個用戶,比如用戶名是db2fence 用戶的home路徑是 /home/db2fence
3. 用 root 用戶,cd /db2_install_path/instances/ 執行 ./db2icrt -u db2fence db2inst1
4. 如果db2icrt 沒有報錯,su - db2inst1 然後 db2start

『柒』 在linux上如何邦定一個db2資料庫

一、安裝前准備工作:
1、對於Linux系統,至ibm網站下載軟體包
2、Linux內核設置:編輯/etc/sysctl.conf文件
3、創建相應用戶以及組:
4、創建相應目錄用於存放db2的數據文件以及日誌文件:
這里在根下面創建一個db2總目錄,然後創建了一個15G大小的邏輯卷掛載/db2下面,然後在其下面創建相應的文件夾。
database目錄存放資料庫實例
db2log1存放db2的主日誌文件
db2log2存放鏡像日誌文件
db2temp存放db2臨時表空間
db2用戶的家目錄的位置
二、安裝過程:
安裝可以使用root用戶安裝也可以使用非root用戶安裝,這里就直接使用root用戶安裝了。
以root身份執行db2setup,會彈出以下畫面:
這里選擇安裝企業版,點擊install new:
下一步之後,就出現創建用戶的畫面:
最後點擊finish開始安裝過程。
三、創建資料庫:
如果在安裝過程中,沒有創建資料庫,則後續可以使用db2cc命令創建資料庫。這是一個基於圖形界面的管理工具,使用起來也非常方便。執行db2cc後,會彈出以下畫面:
點擊右側的Create New Database,創建資料庫:
指定資料庫名稱以及存放位置,選中Let DB2 manage my storage,下一步:
點擊finish開始創建。默認db2會創建以下三個表空間:
(1)、catalog table space用於存放catalog表。
(2)、user table space存放所有表和索引數據。
(3)、temporary table space臨時數據的存放位置。
創建完成後,會看到如下畫面:
此時還沒有連接到xzxjdb1上,點擊右側的connect進行連接。連接之後,會看到右側多了好多信息:
使用命令行查看當前資料庫中表空間信息:
四、DB2的簡單管理:
1、查看錶空間信息:
2、查看錶信息:
3、查看當前實例下的所有資料庫信息:
4、停止資料庫:
5、啟動資料庫:
6、設置實例自動啟動:
《Linux就該這么學》里有相關介紹,建議看看。

閱讀全文

與linux命令行連接db2相關的資料

熱點內容
python量化交易pdf 瀏覽:725
照片如何加密不佔內存 瀏覽:965
手機怎麼下載小恆錢包app 瀏覽:849
閃電伺服器是什麼 瀏覽:111
單片機入門視頻教程第二課 瀏覽:45
天然氣可壓縮多少倍 瀏覽:238
程序員面試評價 瀏覽:128
手錶加密門禁卡 瀏覽:238
psf已加密 瀏覽:553
返利app怎麼用教程 瀏覽:888
一個程序員寫的詩火了 瀏覽:613
red攝影機壓縮比 瀏覽:410
app賬號怎麼弄 瀏覽:823
hc0551單片機 瀏覽:755
噴淋管道支架演算法 瀏覽:592
壓縮機壞了電腦無法啟動 瀏覽:241
不小心加密了怎麼去掉 瀏覽:955
linux命令行連接db2 瀏覽:899
洪恩app怎麼設置護眼模式 瀏覽:971
小猿口算app怎麼選課時 瀏覽:422