Tuesday, May 20, 2014

Loading data Using SQL Loader.

I just tried to  Load sample data using SQLLOADER.

Actual data resides on  a flap file  delimited by "," symbol.

First i created a sample table to hold data.

 CREATE TABLE Test ( 
  ARTICLE_ID   NUMBER PRIMARY KEY , 
  AUTHOR       VARCHAR2(30), 
  FORMAT       VARCHAR2(30), 
  PUB_DATE     DATE, 
  TITLE        VARCHAR2(256), 
 );

Then run the following command to load  the data.

Make sure you have to connect sqlloader with SYSDBA  user account and  you need to provide a control file and the log file.Control file consist with What steps to be carried out when loading and Log file is used for logging purposes.

Here you see loader1.dat file 
-----------------------------------------------------------
load data
INFILE 'loader2.dat'
INTO TABLE articles_formatted
APPEND
FIELDS TERMINATED BY ','
(article_id SEQUENCE (MAX,1),
 author CHAR(30),
 format,
 pub_date SYSDATE,
 title,
 ext_fname FILLER CHAR(80) )
 
------------------------------------------------------------

There you could see the loader2.dat file.That is the actual flapfile file.

Ben Kanobi, plaintext,Kawasaki news article,
Joe Bloggs, plaintext,Java plug-in,
John Hancock, plaintext,Declaration of Independence,
M. S. Developer, Word7,Newsletter example,
M. S. Developer, Word7,Resume example,
X. L. Developer, Excel7,Common example,
X. L. Developer, Excel7,Complex example,
Pow R. Point, Powerpoint7,Generic presentation,
Pow R. Point, Powerpoint7,Meeting presentation,
Java Man, PDF,Java Beans paper,
Java Man, PDF,Java on the server paper,
Ora Webmaster, HTML,Oracle home page,
Ora Webmaster, HTML,Oracle Company Overview,
John Constable, GIF,Laurence J. Ellison : portrait,
Alan Greenspan, GIF,Oracle revenues : Graph,
Giorgio Armani, GIF,Oracle Revenues : Trend,
  
Pleas make sure above file end up with "," symbol.






No comments:

Post a Comment