首頁 資料庫 mysql教程 DB2数据库运维常用命令集锦

DB2数据库运维常用命令集锦

Jun 07, 2016 pm 05:19 PM
db2 oracle 資料庫

在执行如下命令时,需要首先在客户端运行中输入db2cmd进行初始化或者su到db2的实例下操作。

在执行如下命令时,需要首先在客户端运行中输入db2cmd进行初始化或者su到db2的实例下操作。

一、常识性命令

1、db2 connect to     --连接到本地数据库名

  db2 connect to user using --连接到远端数据库

2、 db2 force application all      --强迫所有应用断开数据库连接

3、db2 backup db db2name  --备份整个数据库数据

  db2 restore db                      --还原数据库

4、db2 list application --查看所有连接(需要连接到具体数据库才能查看)

5、db2stop --停止数据库  db2start    --启动数据库

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/db2inst2

db2look -d -u -t   -e -o .sql   --导出数据库中表1和表2的表结构

db2move export              --导出数据库数据

db2move export -tn ,       --导出数据库中表和表数据

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                            --查看数据库中所有表结构

     db2 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的字段进行值转换

例如:select coalesce(id,1)  from     --对表中id如果为null转换成1

二、导入数据:

1、 以默认分隔符加载,默认为“,”号

    db2 "import from btpoper.txt of del insert into btpoper"

2、 以指定分隔符“|”加载

    db2 "import from btpoper.txt of del modified by coldel| insert into btpoper"

三、卸载数据:

1、 卸载一个表中全部数据

    db2 "export to btpoper.txt of del select * from btpoper"

    db2 "export to btpoper.txt of del modified by coldel| select * from btpoper"

2、 带条件卸载一个表中数据

    db2 "export to btpoper.txt of del select * from btpoper where brhid='907020000'"

    db2 "export to cmmcode.txt of del select * from cmmcode where codtp='01'"

    db2 "export to cmmcode.txt of del modified by coldel| select * from cmmcode where codtp='01'"

四、查询数据结构及数据:

    db2 "select * from btpoper"

    db2 "select * from btpoper where brhid='907020000' and oprid='0001'"

    db2 "select oprid,oprnm,brhid,passwd from btpoper"

五、删除表中数据:

    db2 "delete from btpoper"

    db2 "delete from btpoper where brhid='907020000' or brhid='907010000'"

六、修改表中数据:

    db2 "update svmmst set prtlines=0 where brhid='907010000' and jobtp='02'"

    db2 "update svmmst set prtlines=0 where jobtp='02' or jobtp='03'"

七、联接数据库

    db2 connect to btpdbs

八、清除数据库联接

    db2 connect reset    断开数据库连接

    db2 terminate        断开数据库连接

    db2 force applications all    断开所有数据库连接

九、备份数据库

1、 db2 backup db btpdbs

2、 db2move btpdbs export

    db2look -d btpdbs -e -x [-a] -o crttbl.sql

linux

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

oracle資料庫日誌會保存多久 oracle資料庫日誌會保存多久 May 10, 2024 am 03:27 AM

oracle資料庫日誌會保存多久

oracle資料庫伺服器硬體配置需求 oracle資料庫伺服器硬體配置需求 May 10, 2024 am 04:00 AM

oracle資料庫伺服器硬體配置需求

oracle需要多少內存 oracle需要多少內存 May 10, 2024 am 04:12 AM

oracle需要多少內存

用oracle資料庫需要多大內存 用oracle資料庫需要多大內存 May 10, 2024 am 03:42 AM

用oracle資料庫需要多大內存

oracle定時任務每天都會執行一次建立步驟 oracle定時任務每天都會執行一次建立步驟 May 10, 2024 am 03:03 AM

oracle定時任務每天都會執行一次建立步驟

oracle資料庫需要多大內存 oracle資料庫需要多大內存 May 10, 2024 am 02:09 AM

oracle資料庫需要多大內存

在PHP中使用MySQLi建立資料庫連線的詳盡教學 在PHP中使用MySQLi建立資料庫連線的詳盡教學 Jun 04, 2024 pm 01:42 PM

在PHP中使用MySQLi建立資料庫連線的詳盡教學

oracle怎麼啟動監聽程序 oracle怎麼啟動監聽程序 May 10, 2024 am 03:12 AM

oracle怎麼啟動監聽程序

See all articles