I have multiple files (f1.log, f2.log, f3.log etc)
Each file has the data in ;
& =
delimited format. (new lines are delimited by ;
and fields are delimited by =
) e.g.
data of f1:
1=a;2=b;3=c
data of f2:
1=p;2=q;3=r
I need to read all these files and import data into table in format:
filename number data
f1 1 a
f1 2 b
f1 3 c
f2 1 p
[...]
I am new to SQL. Can you please guide me, how can do it?
Use SQL*Loader to get the files into a table. Assuming you have a table created a bit like:
Then you can use the following control file:
However, you will need a different control file for each file. This can be done by making the control file dynamically using a shell script. A sample shell script can be:
Saved as
flog.sh
it can then be run like: