Home » RDBMS Server » Server Utilities » data load problem !!
data load problem !! [message #158188] Wed, 08 February 2006 21:32 Go to next message
AlinaC
Messages: 45
Registered: November 2005
Location: India
Member

Employee Datafile
Tom, 1/B-XYZ street
Jon, 1/C-XYZ Street

Above is a sample data file. Now I would like to import the data into an Oracle table called employee using Oracle 9i SQL Loader utility. But the table has 5 fields (Emp_no,Name , Address,Phone),where as data file has only 3 fields. Is it possible to load data into the table using the above data file? In the table for Emp_no and Phone I would like to put NULL initially.



Regards,
Alina
Re: data load problem !! [message #158208 is a reply to message #158188] Thu, 09 February 2006 01:19 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Use SQL*Loader, just don't specify those two columns in the control file.

_____________
Ross Leishman
Re: data load problem !! [message #158907 is a reply to message #158188] Wed, 15 February 2006 00:50 Go to previous messageGo to next message
AlinaC
Messages: 45
Registered: November 2005
Location: India
Member

Now I would like to put oracle table's default values in some of the fileds for which I'm not inserting values from data file.How to do it?


Regards,
Alina.
Re: data load problem !! [message #158913 is a reply to message #158907] Wed, 15 February 2006 01:01 Go to previous messageGo to next message
tarundua
Messages: 1080
Registered: June 2005
Location: India
Senior Member

check this out

http://www.orafaq.com/faq/can_one_modify_and_add_data_as_the_database_gets_loaded
Re: data load problem !! [message #158919 is a reply to message #158907] Wed, 15 February 2006 01:29 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
>>Now I would like to put oracle table's default values in some of the fileds for which I'm not inserting values from data file.How to do it?


If you want to use some default value if you encounter NULL , then use INTEGER EXTERNAL
or
If the field value is a constant one, use CONSTANT.
oracle@mutation#cat myctl.ctl

LOAD DATA
INFILE 'mydata.data'
INTO TABLE mytable
TRUNCATE
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(
CODE CHAR,
STATUS INTEGER EXTERNAL "nvl(:STATUS,'S')"
)

oracle@mutation#cat mydata.data

1,a
2
3,b
4,c



oracle@mutation#sqlldr userid=scott/tiger control=myctl.ctl
SQL*Loader: Release 9.2.0.4.0 - Production on Mon Feb 13 19:52:07 2006
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Commit point reached - logical record count 5

oracle@mutation#query mutation  scott.mytable

CO S
-- -
1  a
2  S
3  b
4  c


-- just changing the controlfile.
oracle@mutation#sqlldr userid=scott/tiger control=myctl.ctl

SQL*Loader: Release 9.2.0.4.0 - Production on Wed Feb 15 02:26:46 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Commit point reached - logical record count 4
oracle@mutation#query mutation scott.mytable

CO S
-- -
1  S
2  S
3  S
4  S

oracle@mutation#cat myctl.ctl
LOAD DATA
INFILE 'mydata.data'
INTO TABLE mytable
TRUNCATE
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(
CODE CHAR,
STATUS CONSTANT 'S'
)
Previous Topic: Multiple INTO TABLE Statements
Next Topic: UTL_FILE Buffer Overflow?
Goto Forum:
  


Current Time: Fri Jul 05 18:42:15 CDT 2024