REORG TABLE 语句压缩与指定的表相关联的数据。
调用
此语句可以在使用 DB2 CLI 函数的应用程序中使用,也可以通过 CLP 发出。
语法
>>-REORG TABLE--table-name--+------------+---------------------><
'-int1--int2-'
描述
REORG TABLE table-name
标识重组操作的表。名称必须标识现有的表。
int1
需要恢复的字节的可选最小百分比。
int2
需要为将要执行的表压缩恢复的最小字节数。
规则
- 可选的值 int1 和 int2 必须一起使用,或全都不用。
- 可选的值 int1 必须是非负数。
- 可选的值 int1 必须介于 0 与 100 之间。
注意事项
- DB2 Everyplace 可以以内部方式调用表重组。
- 第一个可选参数是表必须包含的不可用的字节的百分比(即百分之十(10)意味“至少百分之十的空间不可用”。)第二个可选参数是表必须包含的不可用的字节数(即 1000 将意味“至少 1000 个字节必须是不可用的空间”。)必须符合两个条件,才可以进行表的实际重组。
- 如果没有指定参数,DB2 Everyplace 对这此选项使用缺省值。缺省百分比是 30 且缺省字节是 6144。因此,“reorg table t1”与“reorg table t1 30 6144”相同。
- 如果重组方式设置为已启用,则 DB2 Everyplace 将自动重组表。如果在 DELETE 或 UPDATE 上启用了重组,则在执行语句之后,会对目标表执行“reorg table table_name 50 30270”。如果在 DROP TABLE 上启用了重组,则在删除表处理结束时执行“reorg table DB2eSYSTABLES 30 10240”(对于 DB2eSYSCOLUMNS 和 DB2eSYSRELS 也是如此)。
- 在 C/C++ 程序中,通过使用具有属性 SQL_ATTR_REORG_MODE 的 CLI/ODBC 函数 SQLSetStmtAttr 设置重组方式。在 JAVA 程序中,通过 DB2eStatement 接口 enableReorg 方法设置重组方式。缺省值是启用重组。
- 重组表时,通过物理上回收删除和更新创建的不可用空间来压缩包含表的数据文件。然后将表的索引更新为指向行的新物理位置。
- 可以重组“DB2 Everyplace 系统目录”基本表。
- 在执行 REORG TABLE 语句时,数据库中不应发生任何其它活动。
示例
使用缺省值压缩 VNNURSE 表。
REORG TABLE VNNURSE
分享到:
相关推荐
db2 reorg table ydd db2 runstats on table ydd with distribution and indexes all 整理表的数据和索引。 13. 导出表数据 db2 export to c:\dftz.txt of del select * from dftz db2 export to c:\dftz.ixf of ...
- **命令**: `db2 reorg table <表名>` - **示例**: `db2 reorg table ydd` - **说明**: 对指定表进行重组,优化性能。 - **运行统计信息**: `db2 runstats on table <表名> with distribution and indexes all` ...
- `db2 reorg table 表名` 对表进行整理,优化物理存储。 - `db2 runstats on table 表名 with distribution and indexes all` 收集表和索引的统计信息。 10. **数据导入导出**: - `db2 export to 文件路径 of ...
- **命令**:`db2 reorg table tb1` - **说明**:对tb1表进行重组,提高性能。 - **重组检查** - **命令**:`db2 reorgchk` - **说明**:检查表是否需要重组。 #### 五、缓冲池管理 - **查看缓冲池** - **...
12. **整理表**:`db2 reorg table <table_name>` - 对表进行重组,优化数据分布和索引,提高查询性能。`db2 runstats on table <table_name> with distribution and indexes all` - 收集表的统计信息,帮助优化器...
- **操作细节**: 使用`db2 reorg table`命令,指定`OFFLINE`选项来进行脱机重组。 #### 六、附:索引重组 **目的**: 通过索引重组提高查询性能。 - **操作细节**: 使用`db2 reorg index`命令进行索引重组操作,以...
db2 reorg table <表名>` - **作用**: 对表进行重组优化。 - **示例**: 对表`ydd`进行重组优化,执行`db2 connect to oyd user db2 using pwd; db2 reorg table ydd`。 - **运行统计信息**: `db2 connect to ...
- **整理表**: 为了提高查询性能,可以使用`db2 reorg table <表名>`命令来整理表的数据分布。例如: ```sql db2 connect to o_yd user db2 using pwd db2 reorg table ydd ``` - **运行统计信息**: 运行统计...
36. **重组表**:`db2 reorg table tb1` 对`tb1`表进行重组,优化表结构。 37. **更新统计信息**:`db2 runstats on table tb1` 更新`tb1`表的统计信息,帮助优化查询计划。 38. **备份数据库**:`db2 backup db ...
- `db2 reorg table <table_name>`:对表进行重新组织。 - `db2 runstats on table <table_name> with distribution and indexes all`:运行统计信息。 **注意事项:** - `<table_name>`应替换为实际的表名。 - ...
`db2reorg table yd` 对表进行重组,优化其物理布局,提升查询性能。通常与`db2runstats on table yd with distribution and indexes all`结合使用,以更新统计信息,进一步优化查询计划。 ### 13. 导出表数据 `...
14. **检查表是否需要重组**:通过`db2 look <表名>`查看表的碎片情况,如果有必要,执行`db2 reorg table <表名>`进行重组以提高查询性能。 15. **对需要重组的表进行重组**:当发现表存在大量碎片或数据分布不均...
使用 `db2 reorg table <表名>` 可以优化表的物理存储,提高查询性能。同时,`db2 runstats on table <表名> with distribution and indexes all` 会收集表的统计信息。 13. **导出表数据**: 数据导出可以使用 `...
- `db2 reorg table ydd`:整理表`ydd`的空间,以提高查询性能。 - `db2 runstats on table ydd with distribution and indexes all`:收集统计信息并分析表`ydd`的数据分布,以优化查询计划。 #### 七、导出与导入...
- **整理表**:`db2 reorg table <table_name>` 用于优化表的物理结构,提高查询效率。 - **运行统计信息**:`db2 runstats on table <table_name> with distribution and indexes all` 更新表的统计信息,帮助...
`db2 reorg table <表名>` 优化表的物理结构,提高查询性能。`runstats` 命令收集统计信息以优化查询计划。 13. **导出表数据**: `db2 export to <输出文件路径> of <格式> select * from <表名>` 将表数据导出...
**命令**: `db2reorg table <table_name>` 和 `db2runstats on table <table_name> with distribution and indexes all` **描述**: 重新组织表的数据,以提高查询性能,并收集统计信息用于优化查询计划。 **示例**...
35. **重组表**:`db2 reorg table [表名]` 对表进行重组以优化存储和性能。 36. **更新统计信息**:`db2 runstats on table [表名]` 更新表的统计信息,帮助优化查询计划。 37. **备份数据库**:`db2 backup db ...
db2 reorg table [表名]` 对表进行整理,优化表的物理布局。 - **运行统计信息**: `db2 connect to [数据库名称] user [用户名] using [密码]; db2 runstats on table [表名] with distribution and indexes all`...