ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling
complimentary technical Workshops on Database Security for the first 30
Oracle Database customers located anywhere in North America, EMEA, LATAM, or
APAC that send an email to
asra_us@oracle.com. Request a Workshop for
your organization today.
Description
Index Organized Tables are tables that, unlike heap tables, are organized like B*Tree indexes.
Note: From Jonathan Lewis on secondary indexes on IOTs
I think secondary indexes on IOTs need some careful testing. It's probably not an area that many people have used in a high-stress environment. There are two main issues:
The primary key is used in the secondary index instead of a rowid so for large primary keys, the index would be bigger than the equivalent index on a simple table.
The secondary index holds a 'guess' block address for the row it points to so that a query can go to the right block more cheaply.
But if the row has moved (e.g. leaf block split) then the guess is wrong and is a cost, not a benefit. But this won't be a problem if your application is always adding data at the 'right-hand' edge of the index.
Depending of version, there are various features and limitations on what you can do with secondary indexes that you will have to trade, balance and test, if you go down that path.
Data Dictionary Objects
ALL_ALL_TABLES
CDB_TAB_COLS
TAB$
ALL_TABLES
COL$
USER_ALL_TABLES
ALL_TAB_COLS
DBA_ALL_TABLES
USER_TABLES
CDB_ALL_TABLES
DBA_TABLES
USER_TAB_COLS
CDB_TABLES
DBA_TAB_COLS
Create
Simple Create IOT
CREATE TABLE <table_name> (
<column_name> <data type and precision>,
<column_name> <data type and precision>,
CONSTRAINT <constraint_name>
PRIMARY KEY (<primary key constraint columns>))
ORGANIZATION INDEX;
Complex IOT with Including Clause And Partitioning
CREATE TABLE <table_name> (
<column_name> <data type and precision>,
<column_name> <data type and precision>,
CONSTRAINT <constraint_name>
PRIMARY KEY (<primary key constraint columns>))
ORGANIZATION INDEX
INCLUDING <column_name>
OVERFLOW TABLESPACE <tablespace_name>
PARTITION BY RANGE (<partitioning_column>)
(<partition definitions>);
-- DDL for the tablespaces required for this demo are [here]
CREATE TABLE labor_hour (
WORK_DATE DATE,
EMPLOYEE_NO VARCHAR2(8),
SUMMIT_WORK_ORDER_NO VARCHAR2(7),
DASH VARCHAR2(2),
CLASS_CODE VARCHAR2(6),
PAYCODE VARCHAR2(2),
ASSIGNED_CREW_NUMBER VARCHAR2(5),
TRANSFER_CREW_NUMBER VARCHAR2(5),
REFERENCE_TYPE VARCHAR2(1),
REFERENCE_NUMBER VARCHAR2(10),
OVERTIME_CODE VARCHAR2(1),
SHIFT_DIFFERENTIAL VARCHAR2(1) NOT NULL,
HOURS NUMBER(4,2) NOT NULL,
MOD_USER_ID VARCHAR2(30) DEFAULT USER,
MOD_USER_DATE DATE DEFAULT SYSDATE,
CONSTRAINT pk_labor_hour
PRIMARY KEY (work_date, employee_no, summit_work_order_no, dash, class_code, paycode, assigned_crew_number, transfer_crew_number, reference_type, reference_number, overtime_code, shift_differential))
ORGANIZATION INDEX
INCLUDING hours
OVERFLOW TABLESPACE uwdata
PARTITION BY RANGE (work_date) (
PARTITION yr06 VALUES LESS THAN (TO_DATE('01-JAN-2017', 'DD-MON-YYYY')) TABLESPACE part1,
PARTITION yr07 VALUES LESS THAN (TO_DATE('01-JAN-2018', 'DD-MON-YYYY')) TABLESPACE part2,
PARTITION yr08 VALUES LESS THAN (TO_DATE('01-JAN-2019', 'DD-MON-YYYY')) TABLESPACE part3,
PARTITION yr99 VALUES LESS THAN (MAXVALUE) TABLESPACE part4);
Mapping Table Clause
Specify MAPPING TABLE to instruct Oracle to create a mapping of local to physical ROWIDs and store them in a heap-organized table. This mapping is needed in order to create a bitmap index on the index-organized table.
Oracle creates the mapping table in the same tablespace as its parent index-organized table.
You cannot query, perform DML operations on, or modify the storage characteristics of the mapping table.
You cannot specify the mapping_table_clause for a partitioned index-organized table.