Please explain SQL* Loader with simple example [message #608936] |
Thu, 27 February 2014 04:33 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/c825fefef08d11db576e1396a25866cb?s=64&d=mm&r=g) |
aaditya321
Messages: 225 Registered: January 2014 Location: Delhi
|
Senior Member |
|
|
I am unable to understand SQL * Loader, please simplify anyone with example, suppose I have .txt file on the our system in D drive then how can .txt file data transfer in our database employee table, need example because I could not understood from helping links docs.oracle.com
|
|
|
Re: Please explain SQL* Loader with simple example [message #608941 is a reply to message #608936] |
Thu, 27 February 2014 05:03 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
As you have a TXT file, you have to create a control file first. It would read that TXT file and load data into the EMPLOYEE table.
Here's a simple example based on Scott's DEPT table (I created an empty one, called DEPT_TEST).
Control file:load data
infile 'm:\a1_maknuto\dept_data.txt'
into table dept_test
replace
fields terminated by ','
trailing nullcols
(
deptno,
dname,
loc
)
Input file (dept_data.txt):1,Accounting,Zagreb
2,Sales,Zadar
3,Operations,Split
Loading session:M:\a1_maknuto>sqlldr scott/tiger@ora10 control=test11.ctl log=test11.log
SQL*Loader: Release 11.2.0.1.0 - Production on ╚et Vel 27 11:59:23 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
Commit point reached - logical record count 3
What have we done:M:\a1_maknuto>sqlplus scott/tiger@ora10
SQL*Plus: Release 11.2.0.3.0 Production on Thu Feb 27 11:59:27 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * From dept_test;
DEPTNO DNAME LOC
---------- -------------- -------------
1 Accounting Zagreb
2 Sales Zadar
3 Operations Split
SQL>
I believe that you should take some time and carefully read SQL*Loader documentation. Basics are simple, but they require some reading anyway. For complex stuff return back here, someone will assist.
|
|
|
|
|
|
|
Re: Please explain SQL* Loader with simple example [message #609043 is a reply to message #609014] |
Fri, 28 February 2014 04:45 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/c825fefef08d11db576e1396a25866cb?s=64&d=mm&r=g) |
aaditya321
Messages: 225 Registered: January 2014 Location: Delhi
|
Senior Member |
|
|
I could unable to understand above statement after that carefully study of SQL*Loader documentation
Please guide me about loading session, where I will execute it, can I execute on sql plus editor or anywhere others.
Please enhance me about Loading session: What have we done: Connected to: That where I will execute, can I execute it on sql plus editor
[EDITED by LF: removed invalid quotes]
[Updated on: Fri, 28 February 2014 04:48] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Please explain SQL* Loader with simple example [message #609081 is a reply to message #609080] |
Sat, 01 March 2014 01:59 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
John Watson
Messages: 8964 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
Hello, LF - I'll have a try, I think you missed something.
Aaditya, you MUST be accurate. Use copy-paste to transfer details from your command prompt to your OraFAQ post. For example, you posted this:
Quote:But when used commond prompt
E:\SQL-Loder>sqlldr hr/hr@ora10 control=test11.ctl log=test11.log
then get problems 'E:\>SQL-Loder>' is not recognized as an internal or external commond.
operable program or batch file.
which is impossible. Look at the characters I have high-lighted in red, it is impossible to get that error from that command. The right angle bracket character, this one: > is nit permitted by the Windows command interpreter as part of a directory or file name. It is permitted as part of prompt. So what did you actually do? Copy/paste the whole command prompt session, and use [code] tags to format it for display
You might also want to consider attending an introductory course in using Windows.
--update: typo
[Updated on: Sat, 01 March 2014 02:00] Report message to a moderator
|
|
|
|
Re: Please explain SQL* Loader with simple example [message #609090 is a reply to message #609083] |
Sat, 01 March 2014 07:17 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I didn't mean that you should leave the forum, but to take some time (at least a few hours) and study documentation. It is pointless to discuss anything about SQL*Loader (please, spell it correctly, its name is NOT "Loder" but "Loader") if you don't even know what is its purpose. You can't expect anyone here to provide that kind of assistance - you must do something by yourself. As I said - basics is on you. Then, if you still have questions, ask.
Another part of your problem is that you don't know how to use Windows' command prompt. There are some commands that let you change disks, enter certain directories, copy files, etc. etc., all of that by typing those commands - no mouse can be used here. It is not your fault - nobody taught you that because GUI is now "in", not many people actually type commands. HOWEVER, as you chose to use Oracle, you have to get used to communicate with it using different tools. SQL*Plus is one of them. SQL Developer is a GUI tool that enables you to do the same as with SQL*Plus, just in a user-friendly manner. Forms lets you create front-end applications that will be used by end users. There are many other Oracle products I didn't even mention; your current task is to use SQL*Loader.
It requires you to know basic basics of the operating system command prompt (as you invoke it from command prompt) as well as basics of SQL*Loader itself.
Once again: forum is not a training course. You'll have to do that elsewhere. We can assist, but not the way you expect it now. I tried to point out what you have to do in both command prompt as well as SQL*Loader (control file, loading seesion ...) but that obviously wasn't enough. I don't know what would you want me to do; I can't go to Delhi and actually *show* you how to find command prompt, how to type commands, why is "E:\>SQL-Loder> not recognized as ...", how to create control file and so forth. There are just too many basic things that you don't know, and until you learn them, you can't expect any progress.
|
|
|
Re: Please explain SQL* Loader with simple example [message #609100 is a reply to message #609078] |
Sat, 01 March 2014 13:12 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/43710.gif) |
Barbara Boehmer
Messages: 9104 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
aaditya321 wrote on Fri, 28 February 2014 23:04For Loading session: I give commond as
E:\SQL-Loder>sqlldr hr/hr@ora10 control=test11.ctl log=test11.log
Where E: is our PC drive name and within its SQL-Loder folder
SQL-Loder is folder name where we stored named of test11.ctl file and dept_data.txt file
Also I have created table named: dept_test on the sql plus editor means database
Now I want to fetch data from dept_data.txt file into table dept_test
But when used commond prompt
E:\SQL-Loder>sqlldr hr/hr@ora10 control=test11.ctl log=test11.log
then get problems 'E:\>SQL-Loder>' is not recognized as an internal or external commond.
operable program or batch file.
Also I could not get why are we using sqlldr, what's its means and one more what it is log=test11.log I am unknow about two parameter
Please explain me about it.
SQL*Loader is an Oracle utility that is used for loading data from text files into Oracle tables. It can be run from the operating system or from SQL*Plus using the HOST command. There is a file named sqlldr.exe that is in a bin sub-directory of the Oracle files on your operating system. From an operating system (command) prompt in that directory, you can type sqlldr to run SQL*Loader. If you are in a different directory and your path is not set to look in the bin directory, then you need to give the complete path that the sqlldr.exe file is in. So, from the operating system you would type:
your_Oracle_path\bin\sqlldr
You can also run SQL*Loader from the command prompt of SQL*Plus by typing:
host sqlldr
By default, when you log in to SQL*Plus, you should be in the correct directory, so you do not need to worry about the path. Also, this can eliminate some potential problems with permissions, so I usually prefer to run SQL*Loader from SQL*Plus. You might trying loggin in to SQL*Plus and type just:
host sqlldr
and see what you get. I believe it should list the possible parameters, such as your username and password and control file.
I also prefer to create the control file from SQL*Plus to avoid any problems with directories or permissions. If you do not create your control file from SQL*Plus in the default directory, then you will need to specify the complete path that your control file is in. You can specify the data file in either your sqlldr command line or in the control file. Once again, if not using the default directory, then you must specify the complete directory path where your data file is. So, a sample command to run SQL*Loader from SQL*Plus would be:
host oracle_path/bin/sqlldr username/password@database_name control=control_file_path/control_file_name data=data_file_path/data_file_name
You would of course substitute the actual paths and values for oracle_path and username and password and database_name and control_file_path and control_file_name and data_file_path and data_file_name.
In your case it would be something like:
host sqlldr hr/hr@ora10 control="E:\SQL-Loder\test11.ctl" data="E:\SQL-Loder\your_data_file.txt" log=test11.log
Note that you need to not have any spaces on either side of the = sign and if you have any spaces or special characters in your path or file names, then you need to enclose them in double quotes.
The log file records the results of your SQL*Loader run, so if it does not load the data as expected, then you can check the log to see what went wrong.
[edit: moved misplaced quotation mark]
[Updated on: Sun, 02 March 2014 11:24] Report message to a moderator
|
|
|
|
|
|
|
|
|