[20190805]Oracle 12c New Feature – Online Partitioning.txt
[20190805]Oracle 12c New Feature – Online Partitioning.txt
--//oracle 12c 支援建立分割槽表新特性,就是線上修改普通表為分割槽表。
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
-------------------- ---------- ---------------------------------------------------------------------------- ------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
SCOTT@test01p> create table tx as select rownum id ,'test' name from dual connect by level<=2e4;
Table created.
SCOTT@test01p> create unique index i_t_id on tx (id);
Index created.
SCOTT@test01p> create index i_t_name on tx (name);
Index created.
SCOTT@test01p> create index i_t_id_name on tx (id,name);
Index created.
--//分析略。
2.測試:
--//session 1,插入不提交。
SCOTT@test01p> insert into tx values (2e4+1,'aaaa');
1 row created.
--//session 2,執行如下:
alter table tx modify partition by range (id)
(PARTITION p1 VALUES LESS THAN (10000),
PARTITION p2 VALUES LESS THAN (20000),
PARTITION px VALUES LESS THAN (MAXVALUE)) ONLINE ;
--//掛起!!
--//session 1:
SCOTT@test01p> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
251 41873 7720:4852 DEDICATED 6316 27 4 alter system kill session '251,41873' immediate;
SCOTT@test01p> @ viewlock
SID SERIAL# USERNAME OSUSER MACHINE MODULE LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2 OWNER OBJECT_TYP OBJECT_NAME BLOCK LOCKWAIT
------ ---------- ---------- ---------- ---------- ------------ --------------- ---------- ---------- ---------- ---------- ------ ---------- -------------------- ----- --------------------
24 45764 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TM DML(TM) Row-X (SX) None 27765 0 SCOTT TABLE TX No 000007FF091426B8
24 45764 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TM DML(TM) Exclusive None 27775 0 SCOTT TABLE SYS_RMTAB$$_H27765 No 000007FF091426B8
24 45764 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TX Transaction None Share 589839 1387 No 000007FF091426B8
24 45764 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TM DML(TM) Exclusive None 27773 0 SCOTT TABLE SYS_JOURNAL_27765 No 000007FF091426B8
24 45764 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TX Transaction Exclusive None 262173 1470 No 000007FF091426B8
251 41873 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TX Transaction Exclusive None 589839 1387 Yes
251 41873 SCOTT ZWS\Admini WORKGROUP\ SQL*Plus TM DML(TM) Row-X (SX) None 27765 0 SCOTT TABLE TX No
7 rows selected.
--//因為session 有事務沒有提交。
SCOTT@test01p> commit ;
Commit complete.
--//session 2,很快建立完成。
SCOTT@test01p> SELECT PARTITION_NAME FROM USER_TAB_PARTITIONS WHERE TABLE_NAME='TX';
PARTITION_NAME
--------------------
P1
P2
PX
SCOTT@test01p> select * from tx where id=1;
ID NAME
---------- --------------------
1 test
SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 6sj645u5hrrbv, child number 0
-------------------------------------
An uncaught error happened in prepare_sql_statement : ORA-01403: no data found
Plan hash value: 419152296
-------------------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | Pstart| Pstop |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100)| | | |
| 1 | PARTITION RANGE SINGLE| | 1 | 10 | 2 (0)| 00:00:01 | 1 | 1 |
|* 2 | INDEX RANGE SCAN | I_T_ID_NAME | 1 | 10 | 2 (0)| 00:00:01 | 1 | 1 |
-------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1
2 - SEL$1 / TX@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"=1)
Note
-----
- Warning: basic plan statistics not available. These are only collected when:
* hint 'gather_plan_statistics' is used for the statement or
* parameter 'statistics_level' is set to 'ALL', at session or system level
--//可以發現索引重新建立,變成了local分割槽索引。
--//你可以發現i_t_id_name也是local分割槽索引。i_t_name是global索引,大家可以自行驗證結果不再貼出。
--//也就是如果建立分割槽表,其原來索引包含分割槽的鍵值並且在前面,建立的索引是字首分割槽索引。而原來索引沒有包含分割槽的鍵值,
--//建立的就是global索引。
--//我的理解這個相當於以前的線上重定義,只不過oracle封裝為1個命令實現了整個過程罷了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2652889/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 12c Automatic ReoptimizationOracle
- Oracle 12C安裝Oracle
- 排錯:New-Object : 找不到型別 [Microsoft.Online.Administration.StrongAuthenticationRequirement]Object型別ROSUIREM
- Oracle 12C Database File Mapping for Oracle ASM FilesOracleDatabaseAPPASM
- Oracle 12c升級指南Oracle
- 12C Oracle ASM Filter DriverOracleASMFilter
- Oracle 12C Statistics on Column GroupsOracle
- sysbench壓測Oracle 12COracle
- benchmark 壓測Oracle 12cOracle
- ORACLE ONLINE PATCH & ORA-00600[kcbgtcr_13]Oracle
- Oracle Data Guard Feature 12cR2系列(二)Oracle
- Oracle Data Guard Feature 12cR2系列(一)Oracle
- Manage SQL Plan Baselines in Oracle 12cSQLOracle
- Oracle 12c CDB&PDBs管理Oracle
- oracle 12c rman備份pdbOracle
- Oracle 12c系列(五)|PDB RefreshOracle
- Oracle 12c系列(六)|Relocate a PDBOracle
- oracle 12c release 2 安裝Oracle
- Oracle 12C 官方文件地圖Oracle地圖
- Oracle 12C新特性-History命令Oracle
- Oracle 12C新特性In-MemoryOracle
- Oracle 12c 兩個新特性Oracle
- Oracle 12c RMAN全攻略Oracle
- Oracle 12.2 新特性: Online PDB relocate (PDB hot move)Oracle
- Oracle 12c系列(十) | 12c中的Recovering Tables and Table PartitionsOracle
- 【OCM】Oracle 12C OCMU 12c OCM升級考試大綱Oracle
- Oracle OCP(34):環境準備(Redhat 7 + Oracle 12c)OracleRedhat
- Oracle 12c 備份與恢復Oracle
- Oracle 12c rac ocr和votedisk管理Oracle
- Oracle 12C Sharding部署和測試Oracle
- Oracle 12C ASM asmcmd amdu_extractOracleASM
- Oracle 12c系列(八)|RMAN (FROM SERVICE)Oracle
- Oracle 12c 關閉歸檔模式Oracle模式
- Oracle 12c nocdb轉換成cdbOracle
- Oracle 12c資料庫安裝Oracle資料庫
- Oracle Goldengate 12c打pus補丁OracleGo
- ORACLE 12C opatch fuser與ChecksystemCommandAvailable failedOracleAI
- Oracle 12c叢集啟動故障Oracle