as
select object_id empno,
object_name ename,
created hiredate,
owner job
from all_objects
( "EMPNO" NUMBER PRIMARY KEY,
"ENAME" VARCHAR2(30),
"HIREDATE" DATE,
"JOB" VARCHAR2(30)
)
organization index --指定表为IOT表
IOT表是将表中的行按索引列的顺序组织,注意IOT表不会像sql server中的聚簇索引那样,会占一些空间,除此以前,IOT同SQL Server的簇索引是一样的,它们都是通过B+树来组织。
PCTTHRESHOLD 在数据块中 超过此百分比部分将存储到overflow指定存储空间
OVERFLOW 指定的超过pctthreshold部分的存储空间
INCLUDING 指定列后的数据将存储到overflow data segment;
SQL> create table test(empno number(4) primary key,
2 ename varchar2(10),job varchar2(9),
3 deptno number(2))
4 organization index
5 pctthreshold 20
6 including ename
7 overflow tablespace example;
Table created.
SQL> select index_name, index_type
2 from user_indexes
3 where table_name='TEST';
INDEX_NAME INDEX_TYPE
------------------------------ ---------------------------
SYS_IOT_TOP_30429 IOT - TOP
SQL> alter table test initrans 3 overflow initrans 5;
Table altered.
SQL> alter table test pctthreshold 15 including job;
Table altered.
SQL> desc test;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
DEPTNO NUMBER(2)
SQL> insert into test
2 values(1002,'aaaa','dba',10);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test;
EMPNO ENAME JOB DEPTNO
---------- ---------- --------- ----------
1002 aaaa dba 10
SQL> alter table test move online;
Table altered.
SQL>
另:
--创建IOT表,没有建mapping table:
CREATE TABLE admin_docindex(
token char(20),
doc_id NUMBER,
token_frequency NUMBER,
token_offsets VARCHAR2(512),
CONSTRAINT pk_admin_docindex PRIMARY KEY (token, doc_id))
ORGANIZATION INDEX
TABLESPACE ecic
PCTTHRESHOLD 20
OVERFLOW TABLESPACE ecic;
--创建 mapping table (先)
alter table admin_docindex ORGANIZATION INDEX mapping table;
--创建bitmap index. (后)
CREATE BITMAP INDEX bix_ad
ON admin_docindex(token_frequency);