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.

CHAPTER 12 ■ DATATYPES 541<br />

support textual information <strong>and</strong> a BLOB does not. But the options we specify for them—the<br />

CHUNKSIZE, PCTVERSION, <strong>and</strong> so on—<strong>and</strong> the considerations are the same, regardless of the base<br />

type. Since BFILEs are significantly different, we’ll discuss them separately.<br />

Internal LOBs<br />

The syntax for a LOB is, on the face of it, very simple—deceptively simple. You may create<br />

tables with column datatypes of CLOB, BLOB, or NCLOB, <strong>and</strong> that is it. They are as simple to use<br />

as the NUMBER, DATE, or VARCHAR2 type:<br />

ops$tkyte@ORA10G> create table t<br />

2 ( id int primary key,<br />

3 txt clob<br />

4 )<br />

5 /<br />

Table created.<br />

Or are they? That small example shows the tip of the iceberg—the bare minimum you can<br />

specify about a LOB. Using DBMS_METADATA, we can get the entire picture:<br />

ops$tkyte@ORA10G> select dbms_metadata.get_ddl( 'TABLE', 'T' )<br />

2 from dual;<br />

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

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

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

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

"TXT" CLOB,<br />

PRIMARY KEY ("ID")<br />

USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255<br />

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

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

TABLESPACE "USERS" ENABLE<br />

) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS 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 />

LOB ("TXT") STORE AS (<br />

TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10<br />

NOCACHE<br />

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

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

The LOB apparently has the following attributes:<br />

• A tablespace (USERS in this example)<br />

• ENABLE STORAGE IN ROW as a default attribute

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

Saved successfully!

Ooh no, something went wrong!