Java Search Engine

freerice.com

Thursday, January 17, 2008

Loading data from a file into a table

How to import data from a file to a table

in Oracle
You have to use sqlldr utility to import data from an external file into a table, you can't do from sql plus.

First you have to create a control file, a data file. Control file should be like this

LOAD DATA
INFILE data file name
APPEND INTO TABLE table name
FIELDS TERMINATED BY 'separator'
(columns list)

Separator is the character which separates the column values in the data file.
Ex:
LOAD DATA
INFILE 'C:\data.txt'
APPEND INTO TABLE ac_mt
FIELDS TERMINATED BY ','
(acname, mtname)

Next call the sqlldr from command prompt and give it control file.

Syntax: sqlldr control='control file name' log='log file name' bad='bad file name'
Any rows which are not imported will be placed into bad file. Details will be logged into the log file.

Read more here.


in MySQL
you can give the same command directly or you can use mysqlimport utility.

Read more here.

No comments:

Ratings by outbrain