oracle hash partition雜湊分割槽(一)
前幾篇文章:http://space.itpub.net/index.php?uid/9240380/action/spacelist/php/1,主要測試
range partition的語法及相關維護;
分割槽表除了範圍分割槽,還有列表分割槽,雜湊分割槽,組合分割槽(是範圍,列表,雜湊各種組合)及子分割槽;
先來測試雜湊分割槽
測試情景:
SQL> select * from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
range partition的語法及相關維護;
分割槽表除了範圍分割槽,還有列表分割槽,雜湊分割槽,組合分割槽(是範圍,列表,雜湊各種組合)及子分割槽;
先來測試雜湊分割槽
測試情景:
SQL> select * from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
---參考資料:
---1,hash partition建立語法1
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 (partition p1 tablespace users,
4 partition p2 tablespace tbs_hang
5 );
Table created.
---2,查詢hash partition表的分割槽及所屬表空間
SQL> select table_name,partition_name,tablespace_name from user_tab_partitions
here table_name='T_HASH_PARTITION';
SQL> select table_name,partition_name,tablespace_name from user_tab_partitions
here table_name='T_HASH_PARTITION';
TABLE_NAME
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
T_HASH_PARTITION
P1
USERS
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
T_HASH_PARTITION
P1
USERS
T_HASH_PARTITION
P2
TBS_HANG
P2
TBS_HANG
TABLE_NAME
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
SQL>
--3,hash partition的分割槽不能變更日誌模式
SQL> alter table t_hash_partition modify partition p1 nologging;
alter table t_hash_partition modify partition p1 nologging
*
ERROR at line 1:
ORA-14252: invalid ALTER TABLE MODIFY PARTITION option for a Hash partition
SQL> alter table t_hash_partition modify partition p1 nologging;
alter table t_hash_partition modify partition p1 nologging
*
ERROR at line 1:
ORA-14252: invalid ALTER TABLE MODIFY PARTITION option for a Hash partition
---4,變更hash partition分割槽的壓縮模式
SQL> alter table t_hash_partition modify partition p1 nocompress;
Table altered.
-----5,具體各個分割槽的表空間及壓縮模式
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 (partition p1 tablespace users compress nologging,
4 partition p2 tablespace tbs_hang
5 );
(partition p1 tablespace users compress nologging,
---標明hash partition不能指定nologging *
ERROR at line 3:
ORA-14176: this attribute may not be specified for a hash partition
ERROR at line 3:
ORA-14176: this attribute may not be specified for a hash partition
----6,以壓縮模式建立表空間
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 (partition p1 tablespace users compress,
4 partition p2 tablespace tbs_hang nocompress
5 )
6 /
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 (partition p1 tablespace users compress,
4 partition p2 tablespace tbs_hang nocompress
5 )
6 /
Table created.
-----7,hash partition建立語法2
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 partitions 2 store in (users,tbs_hang) --括號中為各分割槽所屬表空間
4 /
Table created.
SQL> select table_name,partition_name,tablespace_name from user_tab_partitions w
here table_name='T_HASH_PARTITION';
here table_name='T_HASH_PARTITION';
TABLE_NAME
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
T_HASH_PARTITION
SYS_P21
USERS
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
T_HASH_PARTITION
SYS_P21
USERS
T_HASH_PARTITION
SYS_P22
TBS_HANG
SYS_P22
TBS_HANG
TABLE_NAME
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
--指定壓縮模式建立hash partition
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 partitions 2 store in (users,tbs_hang)
4 compress
5 /
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 partitions 2 store in (users,tbs_hang)
4 compress
5 /
Table created.
---如分割槽數大於指定的表空間數,則採用迴圈使用空間
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 partitions 3 store in (users,tbs_hang) compress;
Table created.
--
SQL> select table_name,partition_name,tablespace_name,compression from user_tab_
partitions where table_name='T_HASH_PARTITION';
TABLE_NAME
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME COMPRESSION
------------------------------------------------------------ ----------------
T_HASH_PARTITION
SYS_P25
USERS ENABLED
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME COMPRESSION
------------------------------------------------------------ ----------------
T_HASH_PARTITION
SYS_P25
USERS ENABLED
T_HASH_PARTITION
SYS_P26
TBS_HANG ENABLED
SYS_P26
TBS_HANG ENABLED
TABLE_NAME
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME COMPRESSION
------------------------------------------------------------ ----------------
------------------------------------------------------------
PARTITION_NAME
------------------------------------------------------------
TABLESPACE_NAME COMPRESSION
------------------------------------------------------------ ----------------
T_HASH_PARTITION
SYS_P27 --------------------自第三個分割槽又開始使用指定的第一個表空間users
USERS ENABLED
SYS_P27 --------------------自第三個分割槽又開始使用指定的第一個表空間users
USERS ENABLED
---指定的表空間數大於分割槽總數,也不報錯,補充:以分割槽總數建立hash partition,各分割槽的名由oracle自動建立,且在user_tab_partitions查不到high_value的值
SQL> create table t_hash_partition(a int,b int)
2 partition by hash(a)
3 partitions 2 store in (users,tbs_hang,t_tbs1)
4 compress
5 /
Table created.
---為了提升hash partition效能,oracle推薦分割槽數為2的冪次方;,即2,4,8...
----插入資料到hash partition
SQL> insert into t_hash_partition select level,level+1 from dual connect by leve
l<3e4;
29999 rows created.
SQL> commit;
Commit complete.
---查詢hash partition表記錄總數
SQL> select count(a) from t_hash_partition;
COUNT(A)
----------
29999
----------
29999
---查詢hash partition分割槽
SQL> select count(a) from t_hash_partition partition(SYS_P28);
COUNT(A)
----------
15140
----------
15140
---查詢hash partition分割槽,可見hash partition把資料打散平均儲存到各個分割槽中
SQL> select count(a) from t_hash_partition partition(SYS_P29);
COUNT(A)
----------
14859
----------
14859
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-752264/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle hash partition雜湊分割槽(二)_操作限制Oracle
- oracle分割槽partition及分割槽索引partition index(一)Oracle索引Index
- 深入解析partition-hash分割槽
- oracle組合分割槽系列二(composite hash partition)Oracle
- oracle分割槽及分割槽索引partition_partition index_維護(一)Oracle索引Index
- oracle reference partition引用分割槽(一)Oracle
- oracle list partition列表分割槽(一)Oracle
- oracle partition分割槽_分割槽列為空測試(一)Oracle
- Oracle 11g 雜湊、LIST分割槽測試Oracle
- ORACLE 範圍分割槽 partition-range分割槽Oracle
- Oracle 分割槽(partition)技術Oracle
- Oracle分割槽表(Partition Table)Oracle
- oracle分割槽及分割槽索引partition_partition index_維護(二)Oracle索引Index
- oracle分割槽及分割槽索引partition_partition index_維護(三)Oracle索引Index
- oracle分割槽及分割槽索引partition_partition index_維護(四)Oracle索引Index
- 分割槽Partition
- 第41期:MySQL 雜湊分割槽表MySql
- oracle分割槽及分割槽索引partition_partition index_維護(五)_快捷方法Oracle索引Index
- Oracle Partition 分割槽詳細總結Oracle
- Redis命令——雜湊(Hash)Redis
- Oracle分割槽表基礎運維-03HASH分割槽Oracle運維
- Oracle分割槽表基礎運維-07增加分割槽(2 HASH分割槽)Oracle運維
- oracle composite partition組合分割槽_composite partition rangeOracle
- MySQL HASH分割槽MySql
- 【實驗】【PARTITION】RANGE分割槽表截斷表分割槽(Truncate Partition)
- 【實驗】【PARTITION】RANGE分割槽表移動表分割槽(Move Partition)
- 分割槽表PARTITION table
- 【實驗】【PARTITION】RANGE分割槽表重新命名錶分割槽(Rename Partition)
- HASH雜湊遊戲原始碼丨HASH雜湊遊戲系統開發丨HASH雜湊遊戲開發成品原始碼部署原始碼遊戲開發
- Oracle Interval Partition 自動分割槽表-實驗Oracle
- Oracle的分割槽修剪介紹:Partition PruningOracle
- oracle11g_system partition系統分割槽Oracle
- MySQL 分割槽表 partition線上修改分割槽欄位MySql
- 【實驗】【PARTITION】RANGE分割槽表合併分割槽
- 【實驗】【PARTITION】RANGE分割槽表增加分割槽
- 【實驗】【PARTITION】RANGE分割槽表刪除分割槽
- 分割槽partition知識點
- MySQL分割槽(Partition)詳解MySql