11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

CHAPTER 12 ■ DATA WAREHOUSING 519Using a simple shell script to load a 189KB Microsoft Word document into the database,you can easily prove the usefulness of the deduplication functionality. The following scripts, theload.ksh shell script and a load.ctl SQL*Loader controlfile, are provided. The function of theload.ksh script is to simply increment the sequence number in the load.ctl file and invoke theSQL*Loader utility. Here’s the content of the load.ksh shell script:# load.kshexport counter_file=load.seqexport controlfile=load.newexport filenum=$(cat $counter_file)(( NUM = $filenum + 1 ))echo $NUM > $counter_filecat load.ctl | sed -e "s/NUMBER_TO_REPLACE###/$NUM/g" > $controlfilesqlldr control=$controlfile userid=rodba/oracle123The load.ctl file is the SQL*Loader controlfile to load a Microsoft Word document in thedatabase. The size of the Word document is approximately 189KB.#load.ctlload data infile *appendinto table docsfields terminated by '|'(document_id,name,blob_content lobfile(name) TERMINATED BY EOF)begindataNUMBER_TO_REPLACE###|Chapter9-ASM.doc||The load.ksh script was invoked 100 times to load 100 copies of the same document intothe DEFAULT_DOCS table. By using the DBMS_SPACE.USED_SPACE procedure, the total bytes allocatedfor the LOB segment can be retrieved. The following simple PL/SQL script was created to retrievethe LOB segment size:REM: space.sqldefine v_tab = '&1'var a number;var b number;var c number;var d number;declarev_used_blocks number;v_total_bytes number;v_segment_blocks number;v_segment_bytes number;v_segment_name varchar2(55);

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

Saved successfully!

Ooh no, something went wrong!