DB2命令


查看当前有多少个数据库 [db2inst1@oc5873237464 ~]$ db2 list db directory
 System Database Directory
 Number of entries in the directory = 1
Database 1 entry:
 Databasealias                      = TEST
 Databasename                       = TEST
 Local databasedirectory            = /home/db2inst1
 Database releaselevel              = 10.00
 Comment                             =
 Directory entrytype                = Indirect
 Catalog database partitionnumber    =0
 Alternate serverhostname           =
 Alternate server portnumber        =
创建数据库 [db2inst1@oc5873237464 ~]$ db2 createdatabase TEST2
DB20000I  The CREATE DATABASE command completedsuccessfully.
创建schema[db2inst1@oc5873237464 elsa]$ db2 create schemaTESTschema
DB20000I  The SQL command completedsuccessfully.
更改密码[root@oc5873237464 html]# passwd db2inst1
Changing password for user db2inst1.

You can now choose the new password.

A valid password should be a mix of upper and lower caseletters,
digits, and other characters.  You can use an 8character long
password with characters from at least 2 of these 4 classes.
An upper case letter that begins the password and a digitthat
ends it do not count towards the number of character classesused,
unless disable_firstupper_lastdigit_check option is enabled.

Enter new password:
Re-type new password:
登入db2inst1用户[root@oc5873237464 html]# su db2inst1
链接TEST2数据库[db2inst1@oc5873237464 html]$ db2 connect toTEST2

   Database ConnectionInformation

 Databaseserver       = DB2/LINUXX8664 10.5.1
 SQL authorizationID   = DB2INST1
 Local databasealias   = TEST2
显示TEST2的表格空间[db2inst1@oc5873237464 html]$ db2 listtablespaces

          Tablespaces for Current Database

 TablespaceID                       = 0
 Name                                = SYSCATSPACE
 Type                                = Database managed space
 Contents                            = All permanent data. Regular table space.
 State                               = 0x0000
   Detailed explanation:
    Normal

 TablespaceID                       = 1
 Name                                = TEMPSPACE1
 Type                                = System managed space
 Contents                            = System Temporary data
 State                               = 0x0000
   Detailed explanation:
    Normal

 TablespaceID                       = 2
 Name                                = USERSPACE1
 Type                                = Database managed space
 Contents                            = All permanent data. Large table space.
 State                               = 0x0000
   Detailed explanation:
    Normal

 TablespaceID                       = 3
 Name                                = SYSTOOLSPACE
 Type                                = Database managed space
 Contents                            = All permanent data. Large table space.
 State                               = 0x0000
   Detailed explanation:
    Normal
列出当前数据库里的表[db2inst1@oc5873237464 html]$ db2 listtables

Table/View                     Schema         Type  Creationtime            
------------------------------- --------------- -------------------------------
  0 record(s) selected.
查看表内部数据[db2inst1@oc5873237464 elsa]$ db2 select * fromUSER_PROFILE 

USER_ID    ONLINE_FLAGINTRANET_ID          USER_NAME                     USER_EMPLOYEE_TYPETEAM_ID    POOL_ID    KEY_BAK1  KEY_BAK2 KEY_BAK3   KEY_BAK4
----------- ----------------------------------------------------------------------------------------------------- ------------------ ---------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------- --------
看表的状态[db2inst1@oc5873237464 ~]$ db2 load query tableSR.USER_PROFILE
Tablestate:
  Set Integrity Pending

除了Set Integrity Pending还有Normal状态。
删除数据库[db2inst1@oc5873237464 xxx]$ db2 drop dbTEST2(Database Name)
DB20000I  The DROP DATABASE command completedsuccessfully.
列出schema中的tables[db2inst1@oc5873237464 xxx]$ db2 list tables forschema
Table/View                     Schema         Type  Creationtime            
------------------------------- --------------- -------------------------------
                       XX               2014-09-24-11.03.16.383915
                         XX               2014-09-24-11.03.17.835145
                            XX               2014-09-24-11.03.19.120613
                          XX               2014-09-24-11.03.20.302117
                          XX               2014-09-24-11.03.21.542803

  5 record(s) selected.
停掉所有应用[db2inst1@ocxxx xxxx]$ db2 force application all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值