SQL *Loader and External Table

Hi,
Can anyone tell me the difference between SQL* Loader and External table?
What are the conditions under we can use SQL * Loader and External Table.
Thanx

External tables are accessible from SQL, which generally simplifies life if the data files are physically located on the database server since you don't have to coordinate a call to an external SQL*Loader script with other PL/SQL processing. Under the covers, external tables are normally just invoking SQL*Loader.
SQL*Loader is more appropriate if the data files are on a different server or if it is easier to call an executable rather than calling PL/SQL (i.e. if you have a batch file that runs on a server other than the database server that wants to FTP a data file from a FTP server and then load the data into Oracle).
Justin

Similar Messages

  • SQL Loader versus External Table

    If anyone has worked on external tables please let me know your views.

    user637544 wrote:
    for sqlldr i follow the following approach
    1. truncate table
    2. call sqlldr and load records in staging table
    3. check for bad records
    how do i tuncate, call external table and check bad records for external table.As part of the SQL*Loader control file you can tell it to truncate the table as part of the process before it loads in the data.
    The key differences between SQL*Loader and External Tables are:
    1. SQL*Loader is an external utility run from the o/s command line, whereas External tables are usable from within SQL and PL/SQL.
    2. SQL*Loader can only load data up into the database, whereas External tables can allow you to read files and write files (10g onwards)
    3. SQL*Loader has limited control on skipping rows etc. whereas External tables can be queried using SQL and has all the flexibility that SQL can offer.
    4. SQL*Loader requires connection information to the database, whereas External tables are already part of the database
    5. SQL*Loader can only change the source filename through dynamic o/s level scripts, whereas External tables can have the filename changed using an ALTER TABLE ... LOCATION ... command.
    If you want to truncate your staging table before loading it with data from the external table, then you will just have to do that as a seperate step, because the external table is not associated with other tables. Simply truncate the other table and then query the data from the external table into the staging table.
    External tables offer a lot more flexibility than using SQL*Loader.

  • Sql loader or external table

    Hi all good morning.
    can we write a stored procedure that loads a file into the table using sql loader?
    can Java call the above stored procedure?
    regards
    raj
    Edited by: user10887630 on Apr 23, 2009 6:18 AM

    Are you saying the files themselves can't be located on the server? or just that the process for loading the files can't be located on the server.
    If the files themselves cannot reside on the server then you won't be able to use SQL*Loader or External tables from within stored procedures. It would require some clever Java code type stuff to get across to a.n.other machine where the files are stored and get the data.
    Typically it is normal for such files to be located on the server. What reasons do the DBA's give for not wanting them there?
    DBA's say that application specific files cannot be maintained on the Database serverSo what are all the database data files then? They hold data from the applications. ;)

  • SQL Loader AND Temporary Tables

    Hi :
    Have a Couple of Questions..
    (1) Is SQL Loader not part of the ORACLE DB 9.X?? Coz I could not find that exe.
    (2) Can we have the Data file on the Client Machine?? OR is it mandatory that the data file should be on the Server to load the data?

    SQL loader is part of Oracle9i and you can use its driver to create external table.Moreover for external tables datafiles should be on server.

  • Sql Loader Vs External table? Which one is preffered?

    Hello guru,
    We trying to load the data into about 160 tables. Here are the following things we are doing currently,
    1. We get the flat file in .txt format
    2. We are writing the control file for each flat file for thier respective tables
    3.And we are using sql loader command to load this data into the table.
    I was wondering if this process is cumbersome, and i m not sure if external table could be simple in loading the tables compared to what we are doing ?And i have not used external tables, so wanted to know which on eis better ? So any idea is greatly appriciated !
    FYI.. Version :- Oracle 11g
    Thank you so much!

    Thanks for you reply justin !
    I found the below example for loading the data into external table...
    CREATE OR REPLACE DIRECTORY dat_dir AS 'C:\Oradata\Data';
    CREATE OR REPLACE DIRECTORY log_dir AS 'C:\Oradata\Log';
    CREATE OR REPLACE DIRECTORY bad_dir AS 'C:\Oradata\Bad';
    GRANT READ ON DIRECTORY dat_dir TO scott;
    GRANT WRITE ON DIRECTORY log_dir TO scott;
    GRANT WRITE ON DIRECTORY bad_dir TO scott;
    CREATE TABLE revext (person      VARCHAR2(20),
                         rev_jan     NUMBER(4),
                         rev_feb     NUMBER(4),
                         rev_mar     NUMBER(4),
                         rev_apr     NUMBER(4),
                         rev_mai     NUMBER(4),
                         rev_jun     NUMBER(4),
                         rev_jul     NUMBER(4),
                         rev_aug     NUMBER(4),
                         rev_sep     NUMBER(4),
                         rev_oct     NUMBER(4),
                         rev_nov     NUMBER(4),
                         rev_dez     NUMBER(4))
    ORGANIZATION EXTERNAL
       TYPE ORACLE_LOADER
       DEFAULT DIRECTORY dat_dir
       ACCESS PARAMETERS
         records delimited by newline
         badfile bad_dir:'revext%a_%p.bad'
         logfile log_dir:'revext%a_%p.log'
         fields terminated by ','
         missing field values are null
         ( person,
           rev_jan,
           rev_feb,
           rev_mar,
           rev_apr,
           rev_mai,
           rev_jun,
           rev_jul,
           rev_aug,
           rev_sep,
           rev_oct,
           rev_nov,
           rev_dez
       LOCATION ('revext.dat')
    PARALLEL 4
    REJECT LIMIT UNLIMITED;
    CREATE TABLE revenue (
        person       VARCHAR2(20),
        month        VARCHAR2(3),
        revenue      NUMBER,
        CONSTRAINT revenue_pk PRIMARY KEY (person,month));
    INSERT INTO revenue (person,month,revenue)
       SELECT person,'Jan',rev_jan
       FROM revext--but currently we are using sql loader, our data looks like this
      1119Smith      01/01/1982AXYZ corporation  xyz corp
      1111collen      01/01/1990AABC corporation  abc corp
         and control file is like this
    INTO TABLE "XYZ_tbl"
       ID                     POSITION(01:05)        CHAR                  "DECODE(RTRIM(:ID), NULL, 'NA', :ID)"       ,
       Name                POSITION(06:15)        CHAR                  "DECODE(RTRIM(:NAME), NULL, 'NA', :Name)"   ,
       Act_dt              POSITION(16:25)        DATE                  "MM/DD/YYYY" NULLIF ACT_DT=BLANKS
    My question is, can i use the options like NULLIF/ DECODE or changing datatypes when loading or functions like REPLACE / TO_DATE in External tables ? Any idea? Any example code or SQL will great
    Thank you so much!

  • SQL*Loader or external table for load a MSG (email) file

    Hi there!
    I'm looking for a way to load an email in a Oracle DB.
    I mean, not all the email's body in a column, but to "parse" it in a multi column/table fashion.
    Is it possible to do with a sql*loader script or an external table?
    I think it is not possible, and that I must switch to XML DB.
    Any idea?
    Thanks,
    Antonio

    Hello,
    Why don't you just load the entire MSG (email) as clob into one email_body column or whatever column name you want to use.
    To load data upto 32k, you can use varchar2(32656) but its not a good idea to load clob in that manner because it's very inconsistent as length can
    vary resulting in string literal too long. So you have 2 choices now, first you have to use either procedure or anonymous block to load clob data.
    First Method -- I loaded alert.log successfully and you can imagine how big this file can be (5MB in my test case)
    CREATE OR REPLACE DIRECTORY DIR AS '/mydirectory/logs';
    DECLARE
       clob_data   CLOB;
       clob_file   BFILE;
    BEGIN
       INSERT INTO t1clob
       VALUES (EMPTY_CLOB ())
       RETURNING clob_text INTO clob_data;
       clob_file   := BFILENAME ('DIR', 'wwalert_dss.log');
       DBMS_LOB.fileopen (clob_file);
       DBMS_LOB.loadfromfile (clob_data,
                              clob_file,
                              DBMS_LOB.getlength (clob_file)
       DBMS_LOB.fileclose (clob_file);
       COMMIT;
    END;Second Method: Use of Sqlldr
    Example of controlfile
    LOAD DATA
    INFILE alert.log "STR '|\n'"
    REPLACE INTO  table t1clob
       clob_text char(30000000)
    )Hope this helps

  • SQL loader  verses External table

    hi
    Can anybody guide me the advantages of External table over SQL Loader in data warehousing environment.
    Or and any URL where I can find suitabel knowledge.
    Thanks in advance.
    Moloy

    here it is.
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14215/et_concepts.htm#sthref1672

  • Sql loader utl_file & external table

    can any one let me know the differences between.
    1.sql loader
    2.utl_file
    3.external table
    Regards.
    Asif.

    To expand on Aron's answer....
    SQL*Loader - An operating system utility which uses control files (which you create) to load data files onto database tables.
    UTL_FILE - A database package which can be used for reading and writing files in any format you care to design programmatically.
    External Table - The latest thing which can be used instead of SQL*Loader. This is done from the database end, by creating a table as an external table and pointing it at the source file on the operating system. It also allows information similar to that put in the SQL*Loader control files to be specified against the table. By querying against the table you are in fact querying against the source file. There are some limitation compared to regular database tables such as there is no ability to write to the external table.
    ;)

  • Sql*loader and nested tables

    I'm having trouble loading a nested table via sqlldr in Oracle 10g and was hoping someone could point me in the right direction. I keep getting the following error:
    SQL*Loader-403: Referenced column not present in table mynamespace.mytable
    Here's an overview of my type and table definitions:
    create type mynamespace.myinfo as object
    i_name varchar2(64),
    i_desc varchar2(255)
    create TYPE mynamespace.myinfotbl as TABLE of mynamespace.myinfo;
    create table mynamespace.mytable
    Info mynamespace.myinfotbl,
    note varchar2(255)
    NESTED TABLE Info STORE AS mytable_nested_tab;
    My control file looks like this:
    load data
    infile 'mydatafile.csv'
    insert into table mynamespace.mytable
    fields terminated by ',' optionally enclosed by '"'
    TRAILING NULLCOLS
    Info nested table count(6)
    Info column object
    i_name char(64),
    i_desc char(255)
    note
    Example mydatafile.csv would be something like:
    lvl1,des1,lvl2,des2,lvl3,des3,lvl4,des4,lvl5,des5,lvl6,des6,a test data set
    I can't figure out why sqlldr keeps rejecting this control file. I'm using 'direct=false' in my .par file.
    Any hints?

    I just noticed that my email is wrong. If you can help, plese send email to [email protected]
    thanks.

  • Sql*loader and relate tables

    I have a file formated like the following:
    111|1,2,3|
    222|7,8|
    Oracle relate table looks like:
    tab1 (id1 number, id2 number)
    Can sql*loader handle this kind of data? I should have 5 records in tab1 once the load is finished.
    tab1 should have:
    111,1
    111,2
    111,3
    222,7
    222,8

    NO
    It will not work like that.
    You have to have data file like
    111|1
    111|2
    111|3
    222|7
    222|8
    Prashant

  • SQL Loader and multiple tables

    I know how to load multiple tables using the same set of data, but is it possible to load multiple tables using a different set of data for each table? Can someone point me to an example or tell me how to set up the ctl file.
    Thanks.

    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10825/ldr_control_file.htm#sthref852
    Distinguishing Different Input Record Formats
    A single datafile might contain records in a variety of formats. Consider the following data, in which emp and dept records are intermixed:
    1 50   Manufacturing       — DEPT record
    2 1119 Smith      50       — EMP record
    2 1120 Snyder     50
    1 60   Shipping
    2 1121 Stevens    60
    A record ID field distinguishes between the two formats. Department records have a 1 in the first column, while employee records have a 2. The following control file uses exact positioning to load this data:
    INTO TABLE dept
       WHEN recid = 1
       (recid  FILLER POSITION(1:1)  INTEGER EXTERNAL,
        deptno POSITION(3:4)  INTEGER EXTERNAL,
        dname  POSITION(8:21) CHAR)
    INTO TABLE emp
       WHEN recid <> 1
       (recid  FILLER POSITION(1:1)   INTEGER EXTERNAL,
        empno  POSITION(3:6)   INTEGER EXTERNAL,
        ename  POSITION(8:17)  CHAR,
        deptno POSITION(19:20) INTEGER EXTERNAL)

  • SQL Loader and Insert Into Performance Difference

    Hello All,
    Im in a situation to measure performance difference between SQL Loader and Insert into. Say there 10000 records in a flat file and I want to load it into a staging table.
    I know that if I use PL/SQL UTL_FILE to do this job performance will degrade(dont ask me why im going for UTL_FILE instead of SQL Loader). But I dont know how much. Can anybody tell me the performance difference in % (like 20% will decrease) in case of 10000 records.
    Thanks,
    Kannan.

    Kannan B wrote:
    Do not confuse the topic, as I told im not going to use External tables. This post is to speak the performance difference between SQL Loader and Simple Insert Statement.I don't think people are confusing the topic.
    External tables are a superior means of reading a file as it doesn't require any command line calls or external control files to be set up. All that is needed is a single external table definition created in a similar way to creating any other table (just with the additional external table information obviously). It also eliminates the need to have a 'staging' table on the database to load the data into as the data can just be queried as needed directly from the file, and if the file changes, so does the data seen through the external table automatically without the need to re-run any SQL*Loader process again.
    Who told you not to use External Tables? Do they know what they are talking about? Can they give a valid reason why external tables are not to be used?
    IMO, if you're considering SQL*Loader, you should be considering External tables as a better alternative.

  • SQL*Loader and binary

    i am trying to load binary data using SQL*Loader. given a table created a la:
    create table oofa ( data raw(500) );
    and a control file (running on x86 linux):
    LOAD DATA
    INFILE *
    APPEND INTO TABLE OOFA
    ( DATA VARRAW(500) )
    BEGINDATA
    X'05003132333435'
    i get an error "variable length field exceeds maximum length" and no record loaded. i tried using X'00053132333435' just in case i'd muffed the big- little-endian stuff, but the same thing happens.
    anyone successfully loaded binary data as above? if so, how'd you do it?
    also, is there a way to make SQL*Loader more verbose?
    thanks.

    i am trying to load binary data using SQL*Loader. given a table created a la:
    create table oofa ( data raw(500) );
    and a control file (running on x86 linux):
    LOAD DATA
    INFILE *
    APPEND INTO TABLE OOFA
    ( DATA VARRAW(500) )
    BEGINDATA
    X'05003132333435'
    i get an error "variable length field exceeds maximum length" and no record loaded. i tried using X'00053132333435' just in case i'd muffed the big- little-endian stuff, but the same thing happens.
    anyone successfully loaded binary data as above? if so, how'd you do it?
    also, is there a way to make SQL*Loader more verbose?
    thanks.

  • SQL Loader and INSERT Trigger

    I have problem and your help to solve it would be very much appreciated.
    I am uploading a text file with SQL Loader into a table. Since I used APPEND option in the Loader, I don't want records to be duplicated. So, I wrote a "BEFORE INSERT .. FOR EACH ROW" trigger to check whether that row already exists or not.
    For example, let us consider a table TEST as follows.
    Fld1     NUMBER(2);
    Fld2     VARCHAR2(10);
    Fld3     VARCHAR2(10);
    I have a trigger on this table.
    CREATE OR REPLACE TRIGGER Trg_Bef_Insert_Test
    BEFORE INSERT ON Test FOR EACH ROW
    DECLARE
    vCount NUMBER(2);
    DuplicateRow EXCEPTION;
    BEGIN
    SELECT Count(*) INTO vCount FROM Test
         WHERE fld1 || fld2 || fld3 = :new.fld1 || :new.fld2 || :new.fld3;
    IF vCount > 0 THEN
         RAISE DuplicateRow;
    END IF;
    EXCEPTION
    WHEN DuplicateRow THEN
         Raise_Application_Error (-20001,'Record already exists');
    WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLCODE || '; ' || SUBSTR(SQLERRM, 1, 150));
    END;
    Please refer to the following SQL statements which I executed in the SQL Plus.
    SQL> insert into test values (1,'one','first');
    1 row created.
    SQL> insert into test values (1,'one','first');
    insert into test values (1,'one','first')
    ERROR at line 1:
    ORA-20001: Record already exists
    ORA-06512: at "CAMELLIA.TRG_TEST", line 13
    ORA-04088: error during execution of trigger 'CAMELLIA.TRG_TEST'
    Would anyone tell me why do errors -6512 and -4088 occur ?
    Also, if you have any other suggestion to handle this situation, please let me know.
    By the way, I am using Oracle 8.1.7.
    Thank you.

    There are a few things wrong here, but you should really use a unique constraint for this.
    SQL> create table t (a number, b number, c number,
      2      constraint uk unique (a, b, c));
    Table created.Here's an example data file with 12 records three of which are duplicates.
    1,2,3
    3,4,5
    6,7,8
    3,2,1
    5,5,5
    3,4,5
    3,2,1
    1,1,1
    2,2,2
    6,7,8
    8,8,8
    9,9,9And a control file
    load data
    infile 'in.dat'
    append
    into table t
    fields terminated by ',' optionally enclosed by '"'
    (a, b, c)Running it with sql loader, inserts the nine records, outputs the three duplicates to a .bad file and logs all the errors in the .log file. No need for triggers or any code.
    $ sqlldr control=in.ctl
    Username:xxx
    Password:
    SQL*Loader: Release 9.2.0.1.0 - Production on Mon Apr 21 23:16:44 2003
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Commit point reached - logical record count 12
    $ cat in.bad
    3,4,5
    3,2,1
    6,7,8
    SQL> select * from t;
             A          B          C
             1          2          3
             3          4          5
             6          7          8
             3          2          1
             5          5          5
             1          1          1
             2          2          2
             8          8          8
             9          9          9
    9 rows selected.

  • Help in calling sql loader and an oracle procedure in a script

    Hi Guru's
    please help me in writing an unix script which will call sql loader and also an oracle procedure..
    i wrote an script which is as follows.
    !/bin/sh
    clear
    #export ORACLE_SID='HOBS2'
    sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    sqlplus USERID=load/ps94mfo16 << EOF
    EXEC DO_TEST_SHELL_SCRIPT
    it is loading the data in to an oracle table
    but the procedure is not executed..
    any valuable suggestion is highly appriciated..
    Cheers

    multiple duplicate threads:
    to call an oracle procedure and sql loader in an unix script
    Re: Can some one help he sql loader issue.

Maybe you are looking for

  • More help for a newbie! Can't get rid of text box lines.

    I've made this document and when I export I'm still seeing the lines around the text from the rectangle tool. How do I get rid of these? Can anyone help me? Thanks!

  • Query Engine Error when adding to repository.

    I'm using Crystal 9.  I am trying to using the Add Command function as a datasource from an ODBC connection.  The SQL is straightforward. Select dbo.CDS_STATDAY.Meta_ID From dbo.CDS_STATDAY I get an error when I select the "Add to Repository" checkbo

  • Not receiving mail to .mac and other mail issue's

    HI all OK first up I cannot recieve any mail to my @mac.com address, when ever I try to send a test email to myself I recieve a bounced email back saying that 'Delivery to the following recipient failed permanently' I have read discussions on this ma

  • This is a disaster

    - Opened in Numbers 2.3 the working well for over a year spreadsheet ABC created in Numbers 2.x - Opened in Numbers 3 the same spreadsheet ABC created in Numbers 2.x - So far no problem - spreadsheet in Numbers 3 seems identical to the one opened in

  • IPad setup - music and photos

    I have recently purchased an iPad 3 and would now like to sort access to my iTunes music content (30gb) and photos (200gb) both of which are stored on an external hard drive which I have connected to a pc. I will shortly be giving my pc to family fam