查看DB2数据库连接信息

1,db2ilist:列出DB2所有实例


[db2inst1@localhost ~]$ db2ilist

db2inst1


2,db2 get instance:显示当前实例


[db2inst1@localhost ~]$ db2 get instance


 The current database manager instance is:  db2inst1


3,db2 list db directory:列出当前实例下的所有数据库


[db2inst1@localhost ~]$ db2 get instance


 The current database manager instance is:  db2inst1


[db2inst1@localhost ~]$ db2 list db directory


 System Database Directory


 Number of entries in the directory = 2


Database 1 entry:


 Database alias                       = TAXDB

 Database name                        = TAXDB

 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                       = TAXCTLDB

 Database name                        = TAXCTLDB

 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         =


4,db2 list active databases:列出当前连接的数据库


[db2inst1@localhost ~]$ db2 list active databases


                           Active Databases


Database name                              = TAXCTLDB

Applications connected currently           = 5

Database path                              = /home/db2inst1/db2inst1/NODE0000/SQL00001/


Database name                              = TAXDB

Applications connected currently           = 7

Database path                              = /home/db2inst1/db2inst1/NODE0000/SQL00002/


5,db2 list applications:列出所有对数据库的连接


[db2inst1@localhost ~]$ db2 list applications


Auth Id  Application    Appl.      Application Id                 DB       # of

         Name           Handle                                    Name    Agents

-------- -------------- ---------- ------------------------------ -------- -----

TAXCTRL  db2jcc_applica 421        AC1CFA65.HF9A.130109004513     TAXCTLDB 1    

TAXCTRL  db2jcc_applica 439        AC1CFA65.I09A.130109004512     TAXCTLDB 1    

TAXCTRL  db2jcc_applica 435        AC1CFA65.H99A.130109004443     TAXCTLDB 1    

TAXCTRL  db2jcc_applica 429        AC1CFA65.H89A.130109004442     TAXCTLDB 1    

TAXCTRL  db2jcc_applica 430        AC1CFA65.H79A.130109004427     TAXCTLDB 1    

TAXCTRL  db2jcc_applica 453        AC1CFA66.HF82.130109004454     TAXDB    1    

TAXCTRL  db2jcc_applica 423        AC1CFA66.HC82.130109004426     TAXDB    1    

TAXCTRL  db2jcc_applica 427        AC1CFA66.HD82.130109004425     TAXDB    1    

TAXCTRL  db2jcc_applica 424        AC1CFA66.HE82.130109004424     TAXDB    1    

TAXCTRL  db2jcc_applica 426        AC1CFA66.H982.130109004354     TAXDB    1    

TAXCTRL  db2jcc_applica 95         C0A82088.P805.130109001447     TAXDB    1    

TAXCTRL  JDBC4DB2       54         NF000001.J74D.000300370017     TAXDB    1    


6,db2 get snapshot for locks on taxdb 查看数据库死锁


[db2inst1@localhost ~]$ db2 get snapshot for locks on taxdb


            Database Lock Snapshot


Database name                              = TAXDB

Database path                              = /home/db2inst1/db2inst1/NODE0000/SQL00002/

Input database alias                       = TAXDB

Locks held                                 = 0

Applications currently connected           = 7

Agents currently waiting on locks          = 0

Snapshot timestamp                         = 2013-01-09 08:50:17.750528


Application handle                         = 475

Application ID                             = AC1CFA66.J782.130109005010

Sequence number                            = 0001

Application name                           = db2jcc_application

CONNECT Authorization ID                   = TAXCTRL

Application status                         = Connect Completed

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected



Application handle                         = 481

Application ID                             = AC1CFA66.J582.130109004941

Sequence number                            = 0015

Application name                           = db2jcc_application

CONNECT Authorization ID                   = TAXCTRL

Application status                         = UOW Waiting

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected



Application handle                         = 461

Application ID                             = AC1CFA66.J482.130109004940

Sequence number                            = 0002

Application name                           = db2jcc_application

CONNECT Authorization ID                   = TAXCTRL

Application status                         = UOW Waiting

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected



Application handle                         = 489

Application ID                             = AC1CFA66.J682.130109004939

Sequence number                            = 0002

Application name                           = db2jcc_application

CONNECT Authorization ID                   = TAXCTRL

Application status                         = UOW Waiting

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected



Application handle                         = 462

Application ID                             = AC1CFA66.J282.130109004909

Sequence number                            = 0006

Application name                           = db2jcc_application

CONNECT Authorization ID                   = TAXCTRL

Application status                         = UOW Waiting

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected



Application handle                         = 95

Application ID                             = C0A82088.P805.130109001447

Sequence number                            = 0002

Application name                           = db2jcc_application

CONNECT Authorization ID                   = TAXCTRL

Application status                         = UOW Waiting

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected



Application handle                         = 54

Application ID                             = NF000001.J74D.000300370017

Sequence number                            = 0004

Application name                           = JDBC4DB2

CONNECT Authorization ID                   = TAXCTRL

Application status                         = UOW Waiting

Status change time                         = Not Collected

Application code page                      = 1208

Locks held                                 = 0

Total wait time (ms)                       = Not Collected

7. 查看当前连接的是哪个库

db2 get connection state 



你可能感兴趣的:(数据库)