`

(转)DB2 3.2.2 表空间维护

    博客分类:
  • DB2
阅读更多

http://book.51cto.com/art/200906/129331.htm

3.2.2 表空间维护(1)

http://book.51cto.com  2009-06-16 10:52  牛新庄  清华大学出版社  我要评论(0)
  • 摘要:《循序渐进DB2-系统管理、运行维护与应用案例》第3章创建数据库和表,本章重点介绍了DB2数据库表空间的管理类型,并指出不同类型之间的优缺点。在表空间部分,还讲述了影响表空间性能的所有选项,如预取大小、扩展大小等,同时又指出操作系统IO设置对表空间性能影响。本节为大家介绍表空间维护。
  • 标签:表空间  DB2  系统管理  循序渐进DB2-系统管理、运行维护与应用案例

 

3.2.2  表空间维护(1)

1. 查看表空间

可以使用DB2 LIST TABLESPACES[SHOW DETAIL]来查看表空间的详细信息。

LAST TABLESPACES命令的输出信息如下:

  1. Tablespaces for Current Database 
  2. Tablespace ID                      = 0  
  3. Name                                 = SYSCATSPACE  
  4. Type                                 = System managed space 
  5. Contents                            = Any data  
  6. State                                = 0x0000  
  7.   Detailed explanation:    Normal  
  8. Tablespace ID                      = 1  
  9. Name                                 = TEMPSPACE1  
  10. Type                                 = System managed space 
  11. Contents                            = System Temporary data  
  12. State                                = 0x0000  
  13.   Detailed explanation:    Normal  
  14. Tablespace ID                      = 2  
  15. Name                                 = USERSPACE1  
  16. Type                                 = System managed space 
  17. Contents                            = Any data  
  18. State                                = 0x0000  
  19.   Detailed explanation:    Normal 

上面所示的这3个表空间是通过CREATE DATABASE命令自动创建的。用户可以通过在该命令中定制表空间选项来覆盖默认的表空间创建选项。但是在创建数据库时必须创建一个系统编目表空间和至少一个常规表空间,以及至少一个系统临时表空间。通过使用CREATE DATABASE命令或以后使用CREATE TABLESPACE命令,可以创建更多的所有类型的表空间(系统表空间除外)。上述3个表空间中,系统编目表空间和系统临时表空间都是只读的,用户不可以在上面创建用户表,如下所示。

  1. C:\Program Files\IBM\SQLLIB\BIN>db2 create table t(i intin  SYSCATSPACE  
  2. DB21034E  该命令被当作SQL语句来处理,因为它是无效的"命令行处理器"命令。在SQL 处理  
  3. 期间,它返回:  
  4. SQL0287N  SYSCATSPACE 不可用于用户对象。 SQLSTATE=42838 

查看表空间及容器的属性

指定LIST TABLESPACES命令的SHOW DETAIL选项将显示其他信息:

  1. LIST TABLESPACES SHOW DETAIL 

默认情况下,将列出创建数据库时所创建的那3个表空间。LlST TABLESPACES SHOW DETAIL命令的输出信息如下:

  1. Tablespaces for Current Database 
  2. Tablespace ID                           = 2  
  3. Name                                    = USERSPACE1  
  4. Type                                    = Database managed space 
  5. Contents                                = Any data  
  6. State                                   = 0x0000  
  7.   Detailed explanation:    Normal  
  8. Total pages                             = 25000---------总页数  
  9. Useable pages                           = 24904--------可用页数  
  10. Used pages                              = 336--------使用页数  
  11. Free pages                              = 24568----空闲页数  
  12. High water mark (pages)             = 336  
  13. Page size (bytes)                   = 4096  
  14. Extent size (pages)                 = 32  
  15. Prefetch size (pages)                   = 16  
  16. Number of containers                = 1 

要列出容器,我们需要使用以上输出中的Tablespace ID:

  1. LIST TABLESPACE CONTAINERS FOR 2 
查看表空间容器的情况,使用LIST TABLESPACE CONTAINERS命令:
  1.           Tablespace Containers for Tablespace 2  
  2. Container ID                       = 0  
  3. Name                                 = C:\DB2\NODE0000\SQL00003\SQLT0002.0  
  4. Type                                 = Path 

该命令将列出指定表空间中的所有容器。如上所示的路径指向容器物理上所在的位置。

表空间状态

查看一个数据库中的表空间的状态,可以使用命令:

  1. list tablespaces show detail 

一个表空间可以有多种不同的状态,如下所示:

  1. 0x0              Normal  
  2. 0x1              Quiesced:SHARE  
  3. 0x2              Quiesced:UPDATE 
  4. 0x4              Quiesced:EXCLUSIVE  
  5. 0x8              Load pending  
  6. 0x10             Delete pending  
  7. 0x20             Backup pending  
  8. 0x40             Rollforward in progress  
  9. 0x80             Rollforward pending  
  10. 0x100            Restore pending  
  11. 0x100            Recovery pending(not used)  
  12. 0x200            Disable pending  
  13. 0x400            Reorg in progress  
  14. 0x800            Backup in progress  
  15. 0x1000           Storage must be defined  
  16. 0x2000           Restore in progress  
  17. 0x4000           Offline and not accessible  
  18. 0x8000           Drop pending  
  19. 0x2000000        Storage may be defined  
  20. 0x4000000        StorDef is in 'final' state  
  21. 0x8000000        StorDef was changed prior to rollforward  
  22. 0x10000000       DMS rebalancer is active  
  23. 0x20000000       TBS deletion in progress  
  24. 0x40000000       TBS creation in progress  
  25. 0x8              For service use only 

关于表空间状态的详细信息,请读者参考"第15章:DB2常见问题总结"中内容。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics