[db2inst1@localhost ~]$ db2ilist
db2inst1
[db2inst1@localhost ~]$ db2 get instance
The current database manager instance is: db2inst1
1.3.查看数据库信息(SCV testTEST testDB 等)[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 5
Database 1 entry:
Database alias = SCV
Database name = SCV
Local database directory = /home/db2inst1
Database release level = 14.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 2 entry:
Database alias = testTEST
Database name = testTEST
Local database directory = /home/db2inst1
Database release level = 14.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
[db2inst1@localhost ~]$ db2 list applications
Auth Id Application Appl. Application Id DB # of
Name Handle Name Agents
-
test db2jcc_applica 131 ::ffff:172.19.6.49.33129.210603102321 testTEST 1
test db2jcc_applica 51 ::ffff:172.19.6.49.33128.210603095759 testTEST 1
test db2jcc_applica 257 ::ffff:172.19.6.49.33133.210603120320 testTEST 1
test db2jcc_applica 132 ::ffff:172.19.6.49.33130.210603102320 testTEST 1
[db2inst1@localhost ~]$ db2 list applications show detail
ConNECT Auth Id Application Name Appl. Application Id Seq# Number of Coordinating Coordinator Status Status Change Time DB Name DB Path
Handle Agents member number pid/thread
- -
test db2fw2 59 *LOCAL.DB2.210603095808 00001 1 0 285 Connect Completed Not Collected testTEST /home/db2inst1/db2inst1/NODE0000/SQL00005/MEMBER0000/
[db2inst1@localhost ~]$ db2 get db cfg for testtest
Database Configuration for Database testtest
Database configuration release level = 0x1400
Database release level = 0x1400
[db2inst1@localhost ~]$ db2 get db cfg for testtest|grep -i “LOGARCHMETH1”
First log archive method (LOGARCHMETH1) = OFF
Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF
Options for logarchmeth1 (LOGARCHOPT1) =
[db2inst1@localhost ~]$ db2 get db cfg for testtest|grep -i “First active log file”
First active log file
[db2inst1@localhost ~]$ db2 connect to testtest
1.10.连接到数据库2[db2inst1@localhost ~]$ db2 connect to testtest user test
Enter current password for test:
Database Connection Information
Database server = DB2/LINUXX8664 11.1.3.3
SQL authorization ID = test
Local database alias = testTEST
[db2inst1@localhost ~]$ db2 connect to testtest user test using Shfwpt@123
Database Connection Information
Database server = DB2/LINUXX8664 11.1.3.3
SQL authorization ID = test
Local database alias = testTEST
[db2inst1@localhost ~]$ db2 connect reset
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$ db2 terminate
DB20000I The TERMINATE command completed successfully.
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$ db2 list tables
Table/View Schema Type Creation time
FEE_TYPE test T 2021-05-27-16.43.40.274489
FEE_TYPE_MER test T 2021-05-27-16.43.41.208940
GROUP_MER_INFO test T 2021-05-27-16.43.41.757482
PT_APP_ENU_DETAIL test T 2021-05-27-16.43.42.317547
[db2inst1@localhost ~]$ db2 list tables for system
Table/View Schema Type Creation time
ATTRIBUTES SYSCAT V 2021-05-27-16.31.20.513169
AUDITPOLICIES SYSCAT V 2021-05-27-16.31.20.596772
[db2inst1@localhost ~]$ db2 list tables for user
Table/View Schema Type Creation time
FEE_TYPE test T 2021-05-27-16.43.40.274489
FEE_TYPE_MER test T 2021-05-27-16.43.41.208940
[db2inst1@localhost ~]$ db2 list tables for schema test
Table/View Schema Type Creation time
FEE_TYPE test T 2021-05-27-16.43.40.274489
1.18.查看表结构[db2inst1@localhost ~]$ db2 describe table test.wx_public_infos
1.19.复制表[db2inst1@localhost ~]$ db2 create table test.test2 like test.wx_public_infos
DB20000I The SQL command completed successfully.
[db2inst1@localhost ~]$ db2 list application show detail |grep -i exe
1.21.查看表空间[db2inst1@localhost ~]$ db2pd -db bpstest -tablespace
1.22.查看死锁1[db2inst1@localhost ~]$ db2 get snapshot for locks on testtest
[db2inst1@localhost ~]$ db2 get snapshot for locks on testtest|grep Locks
Locks held = 0
Locks held = 0
Locks held = 0
Locks held = 0
Database Lock Snapshot
Database name = testTEST
Database path = /home/db2inst1/db2inst1/NODE0000/SQL00005/MEMBER0000/
Input database alias = testTEST
Locks held = 0
Applications currently connected = 5
Agents currently waiting on locks = 0
Snapshot timestamp = 2021-06-04 09:34:20.657933
[db2inst1@localhost ~]$ db2top -d testtest >l
Application Handle(Stat) 最大的消耗资源最多
1250(i) 0.00% 0.00% 3.59% UOW Waiting in the application db2bp 0 0 0 0 0 448.0K 1 0 0 0 0
db2look -d db2Name -e -t tableName-o ddl.sql
1.25. 导出多张指定表数据db2move db2Name export -tn tableName1,tableName2-sn schemaName(多张表以,间隔分开)
(导出的DB2数据会以ixf以及msg文件保存下来)
db2look -d db2Name -z tableSpaceName -e -o tableSpaceDDL.sql
(导出的数据会以ixf以及msg文件保存下来,DDL以.sql文件保存)
db2 -tvf ddl.sql -Z ddl.log
(-Z是对导入表结构输出log文件)
导出
export to tabname.ixf of ixf messages msg.out select * from tabname;
db2look -d testdb -e -t tablename
-d 后面的参数 数据库名称
-e 生成DDl
-t 表名



