DB2表压缩功能
实际上DB2表压缩的方法是通过查看整个表,找到重复的字符和字符串后,将那些字符和字符串存储在一个压缩字典中,然后用一个存储在字典中对应数据字符串的替代符号来替代表中的实际数据,从而达到了压缩数据的目的。一个压缩属性的表,肯定有他所对应的压缩字典。开启表的压缩功能:
Sql代码 http://zhuhichn.iyunv.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=create%20table%20tableName%20compress%20yes%20%E6%88%96%20alter%20table%20tableName%20compress%20yes
[*]create table tableName compress yes 或 alter table tableName compress yes
扫描表并创建对应的压缩字典,并执行实际的表重组,从而压缩数据(每个表都有自己的压缩字典,新插入的数据也会继续被压缩):
Sql代码 http://zhuhichn.iyunv.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=reorg%20table%20tableName%20resetdictionary
[*]reorg table tableName resetdictionary
对于压缩后的表,如果想进行一次表重组,而不是重建数据字典,那么:
Sql代码 http://zhuhichn.iyunv.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=reorg%20table%20tableName%20keepdictionary
[*]reorg table tableName keepdictionary
在压缩前,我们通常想先评估一下表压缩后能节省多少空间可以利用db2 inspect和db2inspf命令来实现:
Sql代码 http://zhuhichn.iyunv.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=db2%20inspect%20rowcompestimate%20table%20name%20tbname%20results%20keep%20tbfile%0A%0Adb2inspf%20tbfile%20alantab_output_RESULTFILE%0A
[*]db2 inspect rowcompestimate table name tbname results keep tbfile
[*]
[*]db2inspf tbfile alantab_output_RESULTFILE
页:
[1]