create table進階學習系列(九)
---語法
{ COMPRESS [ BASIC
| FOR { OLTP
| { QUERY | ARCHIVE } [ LOW | HIGH ]
}
]
| NOCOMPRESS
}
{ COMPRESS [ BASIC
| FOR { OLTP
| { QUERY | ARCHIVE } [ LOW | HIGH ]
}
]
| NOCOMPRESS
}
--測試
---預設非壓縮建表
SQL> create table t_test(a int);
Table created
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> commit;
Commit complete
---未壓縮表大小
SQL> select bytes/1024/1024 mb from user_segments where segment_name='T_TEST';
MB
----------
22
SQL> drop table t_test purge;
Table dropped
SQL> create table t_test(a int);
Table created
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> commit;
Commit complete
---未壓縮表大小
SQL> select bytes/1024/1024 mb from user_segments where segment_name='T_TEST';
MB
----------
22
SQL> drop table t_test purge;
Table dropped
--- compress basic用於direct-path insert情景下壓縮資料,imp不支援direct-path insert,故不能匯入壓縮格式的資料
--- 使用pctfree為0最大化壓縮資料
--- 早期版本,叫作dss table壓縮,用compress for direct_load開啟,此語法已deprectated
SQL> create table t_test(a int) compress basic;
Table created
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> commit;
Commit complete
SQL> select bytes/1024/1024 mb from user_segments where segment_name='T_TEST';
MB
----------
20
SQL> drop table t_test purge;
Table dropped
---compress for oltp,用於oltp環境,pctfree為10,適用於dml表時壓縮資料
SQL> create table t_test(a int) compress for oltp;
Table created
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> commit;
Commit complete
SQL> select bytes/1024/1024 mb from user_segments where segment_name='T_TEST';
MB
----------
22
SQL> drop table t_test purge;
Table dropped
--而如下的compress for query和compress for archive適用於Exadata一體機儲存情景,如下測試也證實此點
SQL> create table t_test(a int) compress for query low;
create table t_test(a int) compress for query low
ORA-64307: hybrid columnar compression is only supported in tablespaces residing on Exadata storage
SQL> create table t_test(a int) compress for archive low;
create table t_test(a int) compress for archive low
ORA-64307: hybrid columnar compression is only supported in tablespaces residing on Exadata storage
--- 使用pctfree為0最大化壓縮資料
--- 早期版本,叫作dss table壓縮,用compress for direct_load開啟,此語法已deprectated
SQL> create table t_test(a int) compress basic;
Table created
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> commit;
Commit complete
SQL> select bytes/1024/1024 mb from user_segments where segment_name='T_TEST';
MB
----------
20
SQL> drop table t_test purge;
Table dropped
---compress for oltp,用於oltp環境,pctfree為10,適用於dml表時壓縮資料
SQL> create table t_test(a int) compress for oltp;
Table created
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> insert into t_test select level from dual connect by level<=9e5;
900000 rows inserted
SQL> commit;
Commit complete
SQL> select bytes/1024/1024 mb from user_segments where segment_name='T_TEST';
MB
----------
22
SQL> drop table t_test purge;
Table dropped
--而如下的compress for query和compress for archive適用於Exadata一體機儲存情景,如下測試也證實此點
SQL> create table t_test(a int) compress for query low;
create table t_test(a int) compress for query low
ORA-64307: hybrid columnar compression is only supported in tablespaces residing on Exadata storage
SQL> create table t_test(a int) compress for archive low;
create table t_test(a int) compress for archive low
ORA-64307: hybrid columnar compression is only supported in tablespaces residing on Exadata storage
---附上compress for query和compress for archive的語義
?When you specify COMPRESS FOR QUERY or COMPRESS FOR ARCHIVE, you enable Hybrid Columnar Compression. With Hybrid Columnar Compression,
data can be compressed during bulk load operations. During the load process, data is transformed into a column-oriented format and then compressed.
Oracle Database uses a compression algorithm appropriate for the level you specify. In general, the higher the level, the greater the compression ratio.
Hybrid Columnar Compression can result in higher compression ratios, at a greater CPU cost. Therefore, this form. of compression is recommended for data that
is not frequently updated.
COMPRESS FOR QUERY is useful in data warehousing environments. Valid values are LOW and HIGH, with HIGH providing a higher compression ratio. The default is HIGH.
COMPRESS FOR ARCHIVE uses higher compression ratios than COMPRESS FOR QUERY, and is useful for compressing data that will be stored for long periods of time.
Valid values are LOW and HIGH, with HIGH providing the highest possible compression ratio. The default is LOW.
Tables with COMPRESS FOR QUERY or COMPRESS FOR ARCHIVE use a PCTFREE value of 0 to maximize compression, unless you explicitly set a value for PCTFREE in the
physical_attributes_clause. For these tables, PCTFREE has no effect for blocks loaded using direct-path INSERT. PCTFREE is honored for blocks loaded using
conventional INSERT, and for blocks created as a result of DML operations on blocks originally loaded using direct-path INSERT.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-753101/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- create table進階學習系列(八)
- create table進階學習系列(五)
- create table進階學習系列(七)
- create table進階學習系列(十一)之cluster
- create table進階學習(一)
- create table進階學習(三)
- create table進階學習(四)
- create table進階學習系列(十一)之cluster_續(二)
- create table進階學習(二)_全域性臨時表_global temporary table
- create table進階學習(二)_dba_free_temp_space_v$tempseg_usage_v$sort_segment
- Node進階學習
- 強化學習(九)Deep Q-Learning進階之Nature DQN強化學習
- oracle create table官方手冊如何快速檢視學習方法Oracle
- Java進階容器學習Java
- create table of mysql databaseMySqlDatabase
- Go 進階學習筆記Go筆記
- Java學習路線·進階Java
- c++學習進階之路
- Swift進階學習筆記Swift筆記
- Git進階學習筆記Git筆記
- JavaScript學習8:DOM進階JavaScript
- Go語言核心36講(Go語言進階技術九)--學習筆記Go筆記
- create a partition table using a exsit table
- Oracle Create Table as SelectOracle
- 讀懂深度學習,走進“深度學習+”階段深度學習
- linux進階命令學習一Linux
- Rust build.rs進階學習RustUI
- Python學習路線·進階Python
- 學習python的進階之路Python
- linux書籍進階學習Linux
- Xcode快捷鍵進階學習XCode
- U-Net學習與進階
- SCO UNIX學習寶典 高階進階(轉)
- 高階前端進階系列 - webview前端WebView
- 【webpack 系列】進階篇Web
- create table if not exists Waiting for table metadata lockAI
- python進階學習筆記(一)Python筆記
- Java進階學習之事件響應Java事件