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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 機器學習進階 第一節 第九課機器學習
- 強化學習(九)Deep Q-Learning進階之Nature DQN強化學習
- create table,show tables,describe table,DROP TABLE,ALTER TABLE ,怎麼使用?
- Java進階容器學習Java
- Go語言核心36講(Go語言進階技術九)--學習筆記Go筆記
- linux進階命令學習一Linux
- Swift進階學習筆記Swift筆記
- Java學習路線·進階Java
- Python學習路線·進階Python
- Go 進階學習筆記Go筆記
- MySQL5.6 create table原理分析MySql
- 讀懂深度學習,走進“深度學習+”階段深度學習
- 高階前端進階系列 - webview前端WebView
- Rust build.rs進階學習RustUI
- 學習NEO開發如何進階
- U-Net學習與進階
- python進階學習筆記(一)Python筆記
- MySQL的create table as 與 like區別MySql
- use azure data studio to create external table for oracleOracle
- 【webpack 系列】進階篇Web
- Koa2進階學習筆記筆記
- Java列舉類學習到進階Java
- HTTP協議學習---(三)進階篇HTTP協議
- 會計進階學習路線圖
- 線段樹進階 學習筆記筆記
- Java進階學習之事件響應Java事件
- React 從入門到進階之路(九)React
- React學習(1)-create-react-appReactAPP
- JS進階系列 --- 繼承JS繼承
- mybatis進行資料庫建表 CREATE command denied to user 'root'@'127.0.0.1' for table 問題MyBatis資料庫127.0.0.1
- Python進階學習之程式碼閱讀Python
- spark學習筆記--進階程式設計Spark筆記程式設計
- Go 語言進階學習路線圖Go
- 機器學習30天進階實戰機器學習
- 圖論進階學習筆記(四)(2024.10.4)圖論筆記
- (一)《SQL進階教程》學習記錄--CASESQL
- Java進階學習之Java架構師的學習路線Java架構
- oracle 19c 無法create table解決Oracle
- DataBinding系列(四):DataBinding進階之路