| Inicio | Tu Cuenta | Manuales | Foros | Tutoriales | Los TOP | Empleos| Artículos | Comentarios |   

Manual Oracle
 1: Monitoreo de Bloqueos 
 2: Manejo de Clusters en Oracle 
 3: Analiszando las Consultas tipo Hash 
 4: Introducción a ORACLE Developer - Castellano 
 5: Creación de un Formulario en Developer Forms - Castellano 
 6: Administracion de Base de Datos Oracle 
 7: Tutorial de Oracle9i Reports 
 8: Manual de Developer Forms 
 9: Manual de Oracle9i Reports 
 10: External tables en Oracle 9i 


Mas de Oracle


Noticias Oracle


Error Ora-


Script Oracle Español
· Scripts para DBA
· SQL ANSI en Oracle 10g
· Pivoting INsert en Oracle 10g
· Sentencias de inserción en varias tablas - Oracle 10g
· Sentencia Insert condicionada - Oracle 10 g

[ Más en la Sección de Noticias ]



External Tables Containing LOB Data
Enviado el Martes, 18 julio a las 15:56:50 por csr

Todo sobre Oracle 10G

External Tables Containing LOB Data


This articles shows how external tables are used to read CLOB and BLOB data, enabling parallel load operations of large quanities of data.
Tomado de: http://www.oracle-base.com/articles/10g/ExternalTablesContainingLobData.php

This articles shows how external tables are used to read CLOB and BLOB data, enabling parallel load operations of large quanities of data.

First, create a directory object pointing to a suitable filesystem directory.
CREATE OR REPLACE DIRECTORY temp_dir AS '/tmp/';
Download the following documents and place them on the filesystem in the location pointed to by the directory object:
The first two documents are plain text files, while the second two are Microsoft Word documents. The documents contain the CLOB and BLOB data to be read by the external table. If you prefer you can create your own documents, but make sure the names are reflected in the datafile below.

The lob_test_data.txt file contains regular data and references to the files holding the CLOB and BLOB data.
1,one,01-JAN-2006,clob_test1.txt,blob_test1.doc
2,two,02-JAN-2006,clob_test2.txt,blob_test2.doc
Now we have all the data, we need an external table to pull it all together.
DROP TABLE lob_tab;

CREATE TABLE lob_tab (
  number_content    NUMBER(10),
  varchar2_content  VARCHAR2(100),
  date_content      DATE,
  clob_content      CLOB,
  blob_content      BLOB
)
ORGANIZATION EXTERNAL
(
  TYPE ORACLE_LOADER
  DEFAULT DIRECTORY temp_dir
  ACCESS PARAMETERS
  (
    RECORDS DELIMITED BY NEWLINE
    BADFILE temp_dir:'lob_tab_%a_%p.bad'
    LOGFILE temp_dir:'lob_tab_%a_%p.log'
    FIELDS TERMINATED BY ','
    MISSING FIELD VALUES ARE NULL
    (
      number_content    CHAR(10),
      varchar2_content  CHAR(100),
      date_content      CHAR(11) DATE_FORMAT DATE MASK "DD-MON-YYYY",
      clob_filename     CHAR(100),
      blob_filename     CHAR(100) 
    )
    COLUMN TRANSFORMS (clob_content FROM LOBFILE (clob_filename) FROM (temp_dir) CLOB,
                       blob_content FROM LOBFILE (blob_filename) FROM (temp_dir) BLOB)
  )
  LOCATION ('lob_test_data.txt')
)
PARALLEL 2
REJECT LIMIT UNLIMITED
/
There are a couple of things to note in this external table definition:
  • The field names of the LOB data (clob_filename, blob_filename) do not match the column names (clob_content, blob_content). This emphasizes these fields in the datafile do not contain the actual data, just filenames where the data can be found.
  • The COLUMN TRANSFORMS clause explains how the CLOB and BLOB data should be loaded. In this case we are using a field from the datafile to identify the filename and a constant for the directory name. To load from multiple directories use an additional field in the datafile to identify directory object.
The following query shows the external table is correctly referencing both the regular data and the LOB data.
COLUMN varchar2_content FORMAT A16
COLUMN date_content FORMAT A12
COLUMN clob_content FORMAT A20

SELECT number_content,
       varchar2_content,
       TO_CHAR(date_content, 'DD-MON-YYYY') AS date_content,
       clob_content,
       DBMS_LOB.getlength(blob_content) AS blob_length
FROM   lob_tab;

NUMBER_CONTENT VARCHAR2_CONTENT DATE_CONTENT CLOB_CONTENT         BLOB_LENGTH
-------------- ---------------- ------------ -------------------- -----------
             1 one              01-JAN-2006  This is a clob test1       24064
             2 two              02-JAN-2006  This is a clob test2       24064

2 rows selected.

SQL>
For more information see:
Hope this helps. Regards Tim...


 
Enlaces Relacionados
· clob_test1.txt
· clob_test2.txt
· blob_test1.doc
· blob_test2.doc
· lob_test_data.txt
· The ORACLE_LOADER Access Driver
· Loading LOB Data Using SQL*Loader
· Más Acerca de Todo sobre Oracle 10G
· Noticias de csr


Noticia más leída sobre Todo sobre Oracle 10G:
Ejemplo de Código JSP (Java Stored Procedures)



Votos del Artículo
Puntuación Promedio: 0
votos: 0

Por favor tómate un segundo y vota por este artículo:

Malo
Regular
Bueno
Muy Bueno
Excelente




Opciones

Versión Imprimible  Versión Imprimible

Enviar a un Amigo  Enviar a un Amigo


Manual Oracle
Oracle Manual y tutorial, Pl/Sql, Discoverer, Forms, Sql y Plsql - Orape



Adaptado para nuke 6.0 por DragónNB