05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

366<br />

CHAPTER 10 ■ DATABASE TABLES<br />

I am going to defer discussion of the PCTTHRESHOLD option at this point, as it is related to<br />

the next two options for IOTs: OVERFLOW <strong>and</strong> INCLUDING. If we look at the full SQL for the next<br />

two sets of tables, T2 <strong>and</strong> T3, we see the following (I’ve used a DBMS_METADATA routine to suppress<br />

the storage clauses, as they are not relevant to the example):<br />

ops$tkyte@ORA10GR1> begin<br />

2 dbms_metadata.set_transform_param<br />

3 ( DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', false );<br />

4 end;<br />

/<br />

ops$tkyte@ORA10GR1> select dbms_metadata.get_ddl( 'TABLE', 'T2' ) from dual;<br />

DBMS_METADATA.GET_DDL('TABLE','T2')<br />

--------------------------------------------------------------------------------<br />

CREATE TABLE "OPS$TKYTE"."T2"<br />

( "X" NUMBER(*,0),<br />

"Y" VARCHAR2(25),<br />

"Z" DATE,<br />

PRIMARY KEY ("X") ENABLE<br />

) ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING<br />

TABLESPACE "USERS"<br />

PCTTHRESHOLD 50 OVERFLOW<br />

PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING<br />

TABLESPACE "USERS"<br />

ops$tkyte@ORA10GR1> select dbms_metadata.get_ddl( 'TABLE', 'T3' ) from dual;<br />

DBMS_METADATA.GET_DDL('TABLE','T3')<br />

--------------------------------------------------------------------------------<br />

CREATE TABLE "OPS$TKYTE"."T3"<br />

( "X" NUMBER(*,0),<br />

"Y" VARCHAR2(25),<br />

"Z" DATE,<br />

PRIMARY KEY ("X") ENABLE<br />

) ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING<br />

TABLESPACE "USERS"<br />

PCTTHRESHOLD 50 INCLUDING "Y" OVERFLOW<br />

PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING<br />

TABLESPACE "USERS"<br />

So, now we have PCTTHRESHOLD, OVERFLOW, <strong>and</strong> INCLUDING left to discuss. These three items<br />

are intertwined, <strong>and</strong> their goal is to make the index leaf blocks (the blocks that hold the actual<br />

index data) able to efficiently store data. An index typically is on a subset of columns. You<br />

will generally find many more times the number of row entries on an index block than you<br />

would on a heap table block. An index counts on being able to get many rows per block.<br />

<strong>Oracle</strong> would spend large amounts of time maintaining an index otherwise, as each INSERT or<br />

UPDATE would probably cause an index block to split in order to accommodate the new data.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!