oracle non-partitioned indexes, global partitioned index and local index partition

1. If in accordance with whether the index partition as the basis for division, Oracle's index types can be divided into non-partitioned indexes, global partitioned index and local index partitions.

 2. Case I

- Create a non-partitioned table

create table text01
 (num1 number, 
 num2 number,
str1 varchar2(10),
str2 varchar2(20))tablespace yysms_cache ;

       
-- data input
INTO Text01 INSERT 
SELECT dbms_random.random () AS num1, - random integer 
round (dbms_random.value (0,1000)) as num2, a random integer from 1 to 1000 
dbms_random.string (opt => 'A' , len => 1) as str1, a random character 
dbms_random.string (opt => 'p' , len => 10) as str2 10 random characters 
from Dual 
Connect by rownum <100; - insert 99 cycles were inserted line data 
commit;
- attempt to create a local partitioned index error
ON Text01 index ix_text01_par Create (num1) 
local (Partition P1, 
       Partition P2, 
       Partition P3); 
--ORA-14016 must partition table base LOCAL partitioned index. The cause of the error is the use of the LOCAL parameters for non-partitioned tables New Index
--- Create a regular index 
create index ix_text01_par on text01(num01);
- Create a global partitioned indexes
CREATE INDEX ix_test01_par ON test01(num2)
   GLOBAL PARTITION BY RANGE (num2)
      (PARTITION p1 VALUES LESS THAN (10000),
       PARTITION p2 VALUES LESS THAN (55000),
       PARTITION p3 VALUES LESS THAN (MAXVALUE));
Conclusion: The non-partitioned table can create a common global partitioned indexes and index partitions can not create local indexes. 
-------------------------------------------------- -----------------------------
-------------------------------------------------------------------------------

3. Case II
- to create a partition table
create table text02(
num1 number,
num2 number,
str1 varchar2(10),
str2 varchar2(20)
) partition by range(num2)
(
partition p1 values less than (10000),
partition p2 values less than (20000),
partition p3 values less than (50000),
partition p4 values less than (70000),
partition p5 values less than (maxvalue)
);

 - attempt to create a local partitioned index

The INDEX ix_text02_par the ON test_partiton_02 the CREATE (NUM) 
local (the PARTITION P1, 
       the PARTITION P2, 
       the PARTITION P3, 
       the PARTITION P4, 
       the PARTITION P5 
       ); 
- number of partitions must be equal to the index of the number of partitions of the underlying table 
--drop index ix_text02_par;
CREATE INDEX ix_text02_par ON text_partiton_02 (num1) local; - above and create an equivalent manner
index ix_text02_par --drop; 
the CREATE INDEX ix_text02_par ON Text02 (num1); - created by default non-partitioned indexes, partition index Caifen global index or local index;
--- create global partitioned indexes
CREATE INDEX ix_text02_par ON text02(num2)
   GLOBAL PARTITION BY RANGE (num2)
      (PARTITION p1 VALUES LESS THAN (10000),
       PARTITION p2 VALUES LESS THAN (55000),
       PARTITION p3 VALUES LESS THAN (MAXVALUE));
-- data input
INTO Text02 INSERT 
SELECT dbms_random.random () AS num1, - random integer 
round (dbms_random.value (0,1000)) as a random integer num2, 1-1000 of 
dbms_random.string (opt => 'A' , len => 1) as str1, a random character 
dbms_random.string (opt => 'p' , len => 10) as str2 10 random characters 
from Dual 
Connect by rownum <100; - insert 99 cycles were inserted line data 
commit;

 

Table 4. Analysis
analyze table text02 compute statistics;
--- Conclusion The general index zoning change and global partitioned indexes will fail only locally partitioned index Haoshi
The best view of index definition statement with the following statement
select dbms_metadata.get_ddl(object_type => 'INDEX',
                             name        => 'IX_TEXT02_PAR')
  FROM DUAL;
        

  



 



  

  

  

 


  

  

  


  

Guess you like

Origin www.cnblogs.com/lyywml/p/12176707.html