<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Oracle Tips and Techniques &#187; Oracle Utilities</title>
	<atom:link href="http://www.oraclecity.com/category/oracle-utilities/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oraclecity.com</link>
	<description>Oracle 11g, Oracle 10g, PL/SQL, Oracle Enterprise Manager 11g Grid Control, Oracle Performance Tuning, Microsoft SQL Server and T-SQL</description>
	<lastBuildDate>Thu, 12 Jan 2012 11:36:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Oracle export commands</title>
		<link>http://www.oraclecity.com/oracle-utilities/oracle-export-commands/</link>
		<comments>http://www.oraclecity.com/oracle-utilities/oracle-export-commands/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 17:30:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle Utilities]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[Oracle FAQ]]></category>
		<category><![CDATA[SQL Tutorial]]></category>

		<guid isPermaLink="false">http://www.oraclecity.com/?p=163</guid>
		<description><![CDATA[Oracle Export utility provides a number of options to help you export your data for different scenarios.
Here are some examples of the most common options that Developers/DBAs use.]]></description>
			<content:encoded><![CDATA[<p>Oracle Export utility provides a number of options to help you export your data for  different scenarios.</p>
<p>Here are some examples of the most common options that Developers/DBAs use.</p>
<p><span style="text-decoration: underline;"><strong><big>Export based on a query: </big></strong></span><br />
You can use thess options to export selected rows from a table. For example below I am  exporting all records from orders table where id &lt; 300    .</p>
<p><em><strong>exp scott/tiger file=test1.dmp query=\&#8221;where id \&lt; 300\&#8221;  tables=orders statistics=none</strong></em></p>
<p>Note above that I am using escape character &#8220;\&#8221;. This will be needed when you  run your export in Unix/Linux environment.<br />
<span id="more-163"></span></p>
<p><span style="text-decoration: underline;"><strong><big>Export selected tables:</big></strong></span><br />
You can use this option to export selected tables. The tables names are separated by comma  (,). In the example below I am exporting orders and customers table data.</p>
<p><em><strong>exp scott/tiger file=test1.dmp tables=orders, customers statistics=none</strong></em></p>
<p><span style="text-decoration: underline;"><strong><big>Exporting with Constraints<br />
</big></strong></span>You can use this option to export data including constraints.</p>
<p><em><strong>exp scott/tiger file=test1.dmp tables=orders, customers statistics=none  constraints=y</strong></em></p>
<p><span style="text-decoration: underline;"><big><strong>Exporting with Feedback option:</strong></big></span><br />
You can use this option to see feedback while export is in progress.<br />
Feedback (format feedback=n where n is a number). Note that each dot (.) represent the  number you entered for feedback. So if you entered 100 then you get more dot.<br />
<em><strong>exp scott/tiger file=test1.dmp tables=orders statistics=none constraints=y  feedback=100</strong></em><br />
About to export specified tables via Conventional Path &#8230;<br />
. . exporting table orders<br />
&#8230;&#8230;&#8230;&#8230;&#8230;<br />
1569 rows exported</p>
<p>But if you enter 100 then you get just one .<br />
<em><strong></strong></em></p>
<p><em><strong>exp scott/tiger file=test1.dmp tables=orders statistics=none constraints=y  feedback=1000</strong></em><br />
About to export specified tables via Conventional Path &#8230;<br />
. . exporting table orders<br />
.<br />
1569 rows exported<br />
Export terminated successfully without warnings.</p>
<p><strong><big><br />
<span style="text-decoration: underline;">Exporting with indexes:</span></big></strong><br />
You can use this option to export data including indexes.</p>
<p><em><strong>exp scott/tiger file=test1.dmp tables=orders statistics=none indexes=y</strong></em></p>
<p><span style="text-decoration: underline;"><strong><big>Exporting with Grants:</big></strong></span><br />
You can use this option to export data including grants..</p>
<p><em><strong>exp scott/tiger file=test1.dmp tables=orders statistics=none grants=y</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.oraclecity.com/oracle-utilities/oracle-export-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL*Loader with example</title>
		<link>http://www.oraclecity.com/oracle-utilities/learn-to-use-sqlloader-with-example/</link>
		<comments>http://www.oraclecity.com/oracle-utilities/learn-to-use-sqlloader-with-example/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 14:14:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oracle Utilities]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[pl/sql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[SQL Tutorial]]></category>
		<category><![CDATA[sql*loader]]></category>

		<guid isPermaLink="false">http://www.oraclecity.com/?p=32</guid>
		<description><![CDATA[A simple and comprehensive guide of using Oracle SQL*Loader. This article explains SQL*Loader with example.]]></description>
			<content:encoded><![CDATA[<p>SQL*LOADER WITH EXAMPLE<br />
========================</p>
<p>SQL*Loader is an Oracle supplied utility used to load data in Oracle tables easily with significantly<br />
high performance. This utility is installed by default when you install Oracle Server software. It is<br />
also installed when you install Administrative version of Oracle Client.</p>
<p>It is commonly used to load data from plain flat files (text files/plain data files) into database tables.<br />
In it&#8217;s simplest form it requires a Control File, a Data File, the SQL*Loader executable and the Target<br />
Table(s).</p>
<p>Control File: As the name suggests this file controls the loading of data in an Oracle table. Data type,<br />
data length, data file separator (called field terminator), target table etc are specified in this file.</p>
<p>Data File: This is a plain text file separated by usually comma (&#8220;,&#8221;) or any other Oracle understandable<br />
characters.</p>
<p>SQL*Loader: This is the sqlldr.exe file supplied by Oracle.</p>
<p>Target Tables(s): Data can be loaded into a single table or multiple tables.</p>
<p>Here is a demonstration of how SQL*Loader is used.<br />
Suppose I have an Oracle table of structure</p>
<p>create table table1<br />
(empno number,<br />
fname varchar2(20),<br />
lname varchar2(20),<br />
age   number<br />
);<br />
I want to load data from a text file named mydatafile.txt which has the following data</p>
<p>1000,David,Selby,40<br />
1001,Thomas,Train,31<br />
1002,Nick,Junior,22<br />
1003,Samantha,Dale,24<br />
1004,Roman,Catfield,39<br />
1005,Punnet,Gupta<br />
1006,Dummy, Suname name does not exists, 10</p>
<p>To load the content of file mydatafile.txt into table table1 I&#8217;ll need to have a control file<br />
which will look somewhat like this:</p>
<p><span id="more-32"></span></p>
<p>LOAD DATA<br />
INFILE &#8216;mydatafile.txt&#8217;<br />
INTO TABLE TABLE1<br />
FIELDS TERMINATED BY &#8216;,&#8217;<br />
TRAILING NULLCOLS<br />
(<br />
empno       INTEGER EXTERNAL NULLIF (empno=BLANKS)<br />
, fname       CHAR NULLIF (fname=BLANKS)<br />
, lname       CHAR NULLIF (lname=BLANKS)<br />
, age         INTEGER EXTERNAL NULLIF (age=BLANKS)<br />
)<br />
Now I have got a Control File, a Data File, sqlldr.exe and a Target Table.</p>
<p>The next step is to actually load data into the table.</p>
<p>To do that you will login to the machine where sqlldr is installed. Depending on O/S you will either need a<br />
Dos command prompt (MS Windows) or the Unix/Linux command prompt. I have run my test on Unix. I am currently<br />
in the directory &#8220;/home/oracle/temp/&#8221; where I have got my control file and my data file. My Oracle user name<br />
is scott (where my table table is was created) and password is tiger and Oracle_SID is ORADEV.</p>
<p>I execute the following command:</p>
<p>$sqlldr <a href="mailto:scott/tiger@ORADEV">scott/tiger@ORADEV</a> control=table1.ctl</p>
<p>And I get the following appear on my screen:</p>
<p>SQL*Loader: Release 11.1.0.7.0 &#8211; Production on Tue Jul 14 11:40:39 2009</p>
<p>Copyright (c) 1982, 2007, Oracle.  All rights reserved.</p>
<p>Commit point reached &#8211; logical record count 7</p>
<p>&#8220;Record count 7&#8243; means that it has processed 7 records, in does not necessarily mean it has inserted all<br />
of the records in the table table1 as we wil lsee in a moment.<br />
Looking at the directory I find there are two new files create called table1.log and mydatafile.bad. The<br />
content of file table1.log looks like this:</p>
<p>[oracle@HTCD-DBOR01 chakma]$ cat table1.log</p>
<p>SQL*Loader: Release 11.1.0.7.0 &#8211; Production on Tue Jul 14 11:40:39 2009</p>
<p>Copyright (c) 1982, 2007, Oracle.  All rights reserved.</p>
<p>Control File:   table1.ctl<br />
Data File:      mydatafile.txt<br />
Bad File:     mydatafile.bad<br />
Discard File:  none specified</p>
<p>(Allow all discards)</p>
<p>Number to load: ALL<br />
Number to skip: 0<br />
Errors allowed: 50<br />
Bind array:     64 rows, maximum of 256000 bytes<br />
Continuation:    none specified<br />
Path used:      Conventional</p>
<p>Table TABLE1, loaded from every logical record.<br />
Insert option in effect for this table: INSERT<br />
TRAILING NULLCOLS option in effect</p>
<p>Column Name                  Position   Len  Term Encl Datatype<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;- &#8212;&#8211; &#8212;- &#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
EMPNO                               FIRST     *   ,       CHARACTER<br />
NULL if EMPNO = BLANKS<br />
FNAME                                NEXT     *   ,       CHARACTER<br />
NULL if FNAME = BLANKS<br />
LNAME                                NEXT     *   ,       CHARACTER<br />
NULL if LNAME = BLANKS<br />
AGE                                  NEXT     *   ,       CHARACTER<br />
NULL if AGE = BLANKS</p>
<p>Record 7: Rejected &#8211; Error on table TABLE1, column LNAME.<br />
ORA-12899: value too large for column &#8220;QRS&#8221;.&#8221;TABLE1&#8243;.&#8221;LNAME&#8221; (actual: 28, maximum: 20)<br />
Table TABLE1:<br />
6 Rows successfully loaded.<br />
1 Row not loaded due to data errors.<br />
0 Rows not loaded because all WHEN clauses were failed.<br />
0 Rows not loaded because all fields were null.<br />
Space allocated for bind array:                  66048 bytes(64 rows)<br />
Read   buffer bytes: 1048576</p>
<p>Total logical records skipped:          0<br />
Total logical records read:             7<br />
Total logical records rejected:         1<br />
Total logical records discarded:        0</p>
<p>Run began on Tue Jul 14 11:40:39 2009<br />
Run ended on Tue Jul 14 11:40:39 2009</p>
<p>Elapsed time was:     00:00:00.12<br />
CPU time was:         00:00:00.03<br />
Special importance should be given to the part</p>
<p>Table TABLE1:<br />
6 Rows successfully loaded.<br />
1 Row not loaded due to data errors.<br />
0 Rows not loaded because all WHEN clauses were failed.<br />
0 Rows not loaded because all fields were null.</p>
<p>It clearly says that &#8220;1 Row not loaded due to data errors&#8221;. So it means that we have not be<br />
able to load all the records from the file. For this example it is quite clear which record<br />
we have the problem with. But when there are thousands or even millions of records into<br />
your flat file then it is not that easy to find out which records failed to load.</p>
<p>That&#8217;s why Oracle automatically created a filed called mydatafile.bad. In this case the file<br />
will have the record &#8220;1006,Dummy, Suname name does not exists, 10&#8243;. As understandtable the<br />
data in the lname field is too large to fit into the column called lname which has the size<br />
of VARCHAR2(20). So it failed to load this record but loaded all other records in the file.</p>
<p>Have a look into the contents of the file table.log and you will find a line where it says</p>
<p>&#8220;ORA-12899: value too large for column &#8220;QRS&#8221;.&#8221;TABLE1&#8243;.&#8221;LNAME&#8221; (actual: 28, maximum: 20)&#8221;.</p>
<p>So this is a very clear error message and tells us why the record was rejected.</p>
<p>How this error will be hanlded is a decision to be taken care by your manager. Possible solution<br />
may be increasing the column length (preffered in this case). Shortening the surname is another<br />
option. But if you have failure on numerous records then you might have to remedy it in the<br />
source and then re-create the data file again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oraclecity.com/oracle-utilities/learn-to-use-sqlloader-with-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

