oracle从9i r2开始推出了compress table的功能,compress table能提供良好的压缩性能,十分适用于存储历史数据。的打算
compress table需要通过创建table时指定compress子句
SQL 9I>create table testcom3(a number) compress;
Table created.
需要通过批量导入数据才能实现compress
1.alter table move
2.create table as select
3.insert
4.direct path sqlldr
下面来看一些例子
SQL 9I>create table test(a varchar2(10),b number);
Table created.
begin
for i in 1..1000 loop
insert into test values(to_char(mod(i,9)),i);
commit;
end loop;
end;
/
PL/SQL procedure successfully completed.
SQL 9I>create table testcom1 compress as select * from test order by a;
Table created.
SQL 9I>set serveroutput on
SQL 9I>exec show_space('TEST');
Unformatted Blocks ..................... 32
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 1
FS4 Blocks (75-100)..................... 26
Full Blocks ..................... 1
Total Blocks............................ 128
Total Bytes............................. 1,048,576
Total MBytes............................ 1
Unused Blocks........................... 64
Unused Bytes............................ 524,288
Last Used Ext FileId.................... 11
Last Used Ext BlockId................... 904
Last Used Block......................... 64
PL/SQL procedure successfully completed.
SQL 9I>exec show_space('TESTCOM1');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 0
Full Blocks ..................... 2
Total Blocks............................ 128
Total Bytes............................. 1,048,576
Total MBytes............................ 1
Unused Blocks........................... 122
Unused Bytes............................ 999,424
Last Used Ext FileId.................... 11
Last Used Ext BlockId................... 1,032
Last Used Block......................... 6
PL/SQL procedure successfully completed.
可以看到compress table提供了良好的压缩比
另外创建compress table的时候还需要注意的是order by子句的功能
create table test2(a varchar2(10),b varchar2(10),c varchar2(10));
begin
for i in 1000000000..1000100000 loop
insert into test2 values(i,'1',to_char(mod(i,100)));
commit;
end loop;
end;
/
create table testcom4 compress as select * from test2 order by c;
create table testcom5 compress as select * from test2;
SQL 9I>exec show_space('TEST2');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 24
Full Blocks ..................... 288
Total Blocks............................ 384
Total Bytes............................. 3,145,728
Total MBytes............................ 3
Unused Blocks........................... 64
Unused Bytes............................ 524,288
Last Used Ext FileId.................... 13
Last Used Ext BlockId................... 1,032
Last Used Block......................... 64
PL/SQL procedure successfully completed.
SQL 9I>exec show_space('TESTCOM4');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 0
Full Blocks ..................... 226
Total Blocks............................ 256
Total Bytes............................. 2,097,152
Total MBytes............................ 2
Unused Blocks........................... 24
Unused Bytes............................ 196,608
Last Used Ext FileId.................... 12
Last Used Ext BlockId................... 1,160
Last Used Block......................... 104
PL/SQL procedure successfully completed.
SQL 9I>exec show_space('TESTCOM5');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 0
Full Blocks ..................... 259
Total Blocks............................ 384
Total Bytes............................. 3,145,728
Total MBytes............................ 3
Unused Blocks........................... 117
Unused Bytes............................ 958,464
Last Used Ext FileId.................... 13
Last Used Ext BlockId................... 1,160
Last Used Block......................... 11
PL/SQL procedure successfully completed.
可见order by子句对compress影响也是比较大,我们应该指定重复值多并且长度大的列做order by以获得最大的压缩比。
compress table需要通过创建table时指定compress子句
SQL 9I>create table testcom3(a number) compress;
Table created.
需要通过批量导入数据才能实现compress
1.alter table move
2.create table as select
3.insert
4.direct path sqlldr
下面来看一些例子
SQL 9I>create table test(a varchar2(10),b number);
Table created.
begin
for i in 1..1000 loop
insert into test values(to_char(mod(i,9)),i);
commit;
end loop;
end;
/
PL/SQL procedure successfully completed.
SQL 9I>create table testcom1 compress as select * from test order by a;
Table created.
SQL 9I>set serveroutput on
SQL 9I>exec show_space('TEST');
Unformatted Blocks ..................... 32
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 1
FS4 Blocks (75-100)..................... 26
Full Blocks ..................... 1
Total Blocks............................ 128
Total Bytes............................. 1,048,576
Total MBytes............................ 1
Unused Blocks........................... 64
Unused Bytes............................ 524,288
Last Used Ext FileId.................... 11
Last Used Ext BlockId................... 904
Last Used Block......................... 64
PL/SQL procedure successfully completed.
SQL 9I>exec show_space('TESTCOM1');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 0
Full Blocks ..................... 2
Total Blocks............................ 128
Total Bytes............................. 1,048,576
Total MBytes............................ 1
Unused Blocks........................... 122
Unused Bytes............................ 999,424
Last Used Ext FileId.................... 11
Last Used Ext BlockId................... 1,032
Last Used Block......................... 6
PL/SQL procedure successfully completed.
可以看到compress table提供了良好的压缩比
另外创建compress table的时候还需要注意的是order by子句的功能
create table test2(a varchar2(10),b varchar2(10),c varchar2(10));
begin
for i in 1000000000..1000100000 loop
insert into test2 values(i,'1',to_char(mod(i,100)));
commit;
end loop;
end;
/
create table testcom4 compress as select * from test2 order by c;
create table testcom5 compress as select * from test2;
SQL 9I>exec show_space('TEST2');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 24
Full Blocks ..................... 288
Total Blocks............................ 384
Total Bytes............................. 3,145,728
Total MBytes............................ 3
Unused Blocks........................... 64
Unused Bytes............................ 524,288
Last Used Ext FileId.................... 13
Last Used Ext BlockId................... 1,032
Last Used Block......................... 64
PL/SQL procedure successfully completed.
SQL 9I>exec show_space('TESTCOM4');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 0
Full Blocks ..................... 226
Total Blocks............................ 256
Total Bytes............................. 2,097,152
Total MBytes............................ 2
Unused Blocks........................... 24
Unused Bytes............................ 196,608
Last Used Ext FileId.................... 12
Last Used Ext BlockId................... 1,160
Last Used Block......................... 104
PL/SQL procedure successfully completed.
SQL 9I>exec show_space('TESTCOM5');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 0
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 0
Full Blocks ..................... 259
Total Blocks............................ 384
Total Bytes............................. 3,145,728
Total MBytes............................ 3
Unused Blocks........................... 117
Unused Bytes............................ 958,464
Last Used Ext FileId.................... 13
Last Used Ext BlockId................... 1,160
Last Used Block......................... 11
PL/SQL procedure successfully completed.
可见order by子句对compress影响也是比较大,我们应该指定重复值多并且长度大的列做order by以获得最大的压缩比。
发表评论
-
ORACLE OEM
2012-04-25 10:30 804OracleEnterpriseManager(Oracle企 ... -
Oracle中Cluster Table的使用(转)
2012-02-27 21:37 966大家对通常oracle中的cluster的理解是不准确的 ... -
Alter table move compress是如何工作的?(转)
2012-02-27 10:23 1083alter table move compress的技术本质是 ... -
oracle分区表
2012-02-22 13:55 632oracle分区表 oracle分区表 1.表空间及分区表的概 ... -
Oracle 字符集转换
2012-02-17 16:33 800从AL32UTF8转换为ZHS16GBK SQL> ... -
ORACLE EXP命令
2012-01-17 16:28 648转自【http://blog.csdn.net/hanghwp ... -
linux下使用crontab实现oracle定时备份
2011-12-15 15:05 14611创建oracle备份脚本创建备份脚本,backuporacl ...
相关推荐
Oracle 10gR2 的压缩(Compress)技术是一种高效的数据存储策略,它能够显著减少数据库占用的物理存储空间,从而节省硬件成本并提高I/O性能。在Oracle数据库中,压缩可以应用于多个层次,包括表、表空间、物化视图、...
无损压缩算法是数据压缩领域的一种重要技术,它在压缩数据的同时能保证解压后的数据与原始数据完全一致。在给定的压缩包文件中,包含了一系列无损压缩算法的实现,如Huffman编码(Huf)、游程编码(RLE)、LZ77、LZW...
SQL> create table T1 (col number) compress; Table created. ``` 对于已经存在的非分区表,如果想将其压缩,可以使用 `ALTER TABLE` 语句,但请注意,这只会对表后续插入的数据生效,不会压缩原有的数据。要压缩...
SQL> alter table tmp_test compress; 取消表的压缩: SQL> alter table tmp_test nocompress; 确定一个表是否使用了压缩,可以查询 user_tables,compression 字段表明表是否被压缩: SQL> select table_name, ...
根据提供的文件信息,该文件名为《ansys-mechanical-users-guidepdf_compress.pdf》,显然是关于ANSYS Mechanical软件的用户指南。ANSYS Mechanical是ANSYS公司开发的一款有限元分析软件,广泛应用于工程仿真领域。...
值得注意的是,压缩后的Feature Class和Table不能编辑,也不能修改坐标系统信息、子类型、属性域、默认值、字段及其属性、表示法。唯一可更改的是Feature Class和Table的别名以及属性索引。在Feature Dataset中,...
ALTER TABLE <table_name> ADD CONSTRAINT <constraint_name> FOREIGN KEY () REFERENCES <referenced_table>() ON DELETE CASCADE; ``` **示例:** ```sql ALTER TABLE stuinfo ADD CONSTRAINT stu_fk FOREIGN KEY ...
CREATE TABLE table_name (columns...) COMPRESS FOR OLTP; ``` - 或者先创建表再使用`ALTER TABLE`语句进行压缩设置: ```sql ALTER TABLE table_name COMPRESS FOR OLTP; ``` 2. **查看压缩状态** - 使用...
标题 "dynamique-table-(1).zip_android" 暗示这是一个与Android应用程序相关的压缩文件,特别是关于图像处理。在Android开发中,图像处理是一项关键技能,它涉及到图像的加载、显示、编辑、滤镜应用等多种操作。让...
- 命令格式: `sqoop import --connect <jdbc_url> --username <username> --password <password> --table <table_name> --target-dir <hdfs_directory>` - 示例命令: `sqoop import --connect jdbc:mysql://...
addition to OLTP Table Compression, the Advanced Compression Option includes a comprehensive set of compression capabilities to help customers maximize resource utilization and reduce costs by ...
(data_compressed_bytes / data_uncompressed_bytes) * 100 as compress_rate, -- 压缩率 max_date - min_date as days, -- 数据跨度天数 size / (max_date - min_date) as avgDaySize -- 平均每天数据量 from ...
最后,将编码后的数据写入JPEG文件,按照JPEG的标准格式组织,包括SOI(Start of Image)、APPn(Application Marker)、SOFn(Start of Frame)、DQT(Quantization Table)、SOS(Start of Scan)等标记。...
创建压缩表时,只需在`CREATE TABLE`语句中添加`COMPRESS`关键字。例如: ```sql CREATE TABLE sale.detail_record (columns...) COMPRESS; ``` 如果已经创建了表,可以通过`ALTER TABLE`语句改变表的压缩属性: ...
"compress": "", "defaultFS": "", "fieldDelimiter": "", "fileName": "", "fileType": "", "path": "", "writeMode": "" } } } ], "setting": { "speed": { "channel": "" } } } } ``` 在这个...
SQLMemTable can compress data on the fly. The compression routines used in the SQLMemTable are much faster than most of popular archivers like PKZip, WinRar, Arj. High performance. - Fast search by B...
exp icdmain/icd rows=y indexes=n compress=n buffer=65536 feedback=100000 volsize=0 file=exp_icdmain_table_yyyymmdd.dmp log=exp_icdmain_table_yyyymmdd.log tables=icdmain.commoninformation,icdmain....
CREATE TABLE images_table ( id INTEGER PRIMARY KEY AUTOINCREMENT, image_data BLOB ); ``` 然后,将图片字节数组插入到表中: ```java SQLiteDatabase db = dbHelper.getWritableDatabase(); ...
PDF2JSON PDF2JSON是基于XPDF(3.02)的转换库,可用于将高性能PDF页面逐页转换为JSON和XML格式。 它还支持压缩数据以最小化大小。...:要转换的最后一页-compress:使用压缩模式-q:不要打印任何消息或错误