05.11.2015 Views

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

362<br />

CHAPTER 10 ■ DATABASE TABLES<br />

5 )<br />

6 organization index<br />

7 OVERFLOW;<br />

Table created.<br />

ops$tkyte@ORA10GR1> create table t3<br />

2 ( x int primary key,<br />

3 y varchar2(25),<br />

4 z date<br />

5 )<br />

6 organization index<br />

7 overflow INCLUDING y;<br />

Table created.<br />

We’ll get into what OVERFLOW <strong>and</strong> INCLUDING do for us, but first let’s look at the detailed SQL<br />

required for the first table:<br />

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

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

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

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

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

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

"Z" DATE,<br />

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

)<br />

ORGANIZATION INDEX<br />

NOCOMPRESS<br />

PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING<br />

STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645<br />

PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)<br />

TABLESPACE "USERS"<br />

PCTTHRESHOLD 50<br />

This table introduces two new options, NOCOMPRESS <strong>and</strong> PCTTHRESHOLD, which we’ll look at<br />

in a moment. You might have noticed that something is missing from the preceding CREATE ➥<br />

TABLE syntax: there is no PCTUSED clause, but there is a PCTFREE. This is because an index is a<br />

complex data structure that isn’t r<strong>and</strong>omly organized like a heap, so data must go where it<br />

“belongs.” Unlike in a heap, where blocks are sometimes available for inserts, blocks are<br />

always available for new entries in an index. If the data belongs on a given block because of its<br />

values, it will go there regardless of how full or empty the block is. Additionally, PCTFREE is used<br />

only when the object is created <strong>and</strong> populated with data in an index structure. It is not used<br />

like it is in the heap organized table. PCTFREE will reserve space on a newly created index, but<br />

not for subsequent operations on it, for much the same reason as PCTUSED is not used at all.<br />

The same considerations for freelists we had on heap organized tables apply in whole to IOTs.

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

Saved successfully!

Ooh no, something went wrong!