<?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>Sys-Admin Information&#039;s &#187; Sql Loader</title>
	<atom:link href="http://sysinfo.bascomp.org/category/oracle/sqlloader/feed/" rel="self" type="application/rss+xml" />
	<link>http://sysinfo.bascomp.org</link>
	<description></description>
	<lastBuildDate>Fri, 23 Apr 2010 09:43:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sql*Loader</title>
		<link>http://sysinfo.bascomp.org/2007/10/sqlloader/</link>
		<comments>http://sysinfo.bascomp.org/2007/10/sqlloader/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 13:08:47 +0000</pubDate>
		<dc:creator>Hendrawan</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Sql Loader]]></category>

		<guid isPermaLink="false">http://sysinfo.bascomp.org/2007/10/17/sqlloader/</guid>
		<description><![CDATA[Preview a little 'bout sql*loader
SQL*Loader loads data from external files into tables of an Oracle database,
SQL*Loader Can manipulate the data before loading it, using SQL functions,
SQL*Loader Can load data into multiple tables during the same load session, and many more..
SQL*Loader takes as input a control file (*.ctl), which controls the behavior of SQL*Loader, and one [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Preview a little 'bout sql*loader</strong><br />
SQL*Loader loads data from external files into tables of an Oracle database,<br />
SQL*Loader Can manipulate the data before loading it, using SQL functions,<br />
SQL*Loader Can load data into multiple tables during the same load session, and many more..</p>
<p>SQL*Loader takes as input a control file (*.ctl), which controls the behavior of SQL*Loader, and one or more datafiles. Output of the SQL*Loader is an Oracle database (where the data is loaded), a log file, a bad file, and potentially a discard file.</p>
<p><strong>Requirement..</strong><br />
1. Table<br />
2. Control File<br />
3. Flat File / Data File (optional)</p>
<p><span id="more-29"></span><br />
<strong>Example</strong></p>
<p>1. ---Create User</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> user loader
<span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> loader
<span style="color: #993333; font-weight: bold;">DEFAULT</span> tablespace loaders
<span style="color: #993333; font-weight: bold;">TEMPORARY</span> tablespace temp</pre></div></div>

<p>---Grant To Tablespace</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">GRANT</span> UNLIMITED TABLESPACE <span style="color: #993333; font-weight: bold;">TO</span> loader</pre></div></div>

<p>---Making A Table</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> loader<span style="color: #66cc66;">.</span>load_here
<span style="color: #66cc66;">&#40;</span>
col1 VARCH4R2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
col2 VARCH4R2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
col3 VARCH4R2<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>2. Add "ctl" file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bash</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> loader.ctl
LOAD DATA
INFILE <span style="color: #ff0000;">'/tmp/flat_file.csv'</span>
REPLACE
INTO TABLE loader.load_here
FIELDS TERMINATED BY <span style="color: #ff0000;">','</span>
TRAILING NULLCOLS
<span style="color: #7a0874; font-weight: bold;">&#40;</span>col1,col2,col3<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>The <strong>INFILE</strong> says, "where file was load"<br />
The <strong>REPLACE</strong> keyword says, "remove any existing rows before starting the load."<br />
<strong> INTO TABLE</strong>, "yes, the table where data was insert"<br />
The <strong>TRAILING NULLCOLS</strong> statement handles the missing data; it tells SQL*Loader to load any missing data as NULL values<br />
<strong> FIELDS TERMINATED BY ','  </strong>says the delimiter from csv file, default is " , "</p>
<p>3. Insert the table with csv file</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">a,nama1,staff
b,nama2,manager
c,nama3,direktur</pre></div></div>

<p><strong>Run SQL*Loader</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bash</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bash</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">ls</span>
loader.ctl
flat_file.csv</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bash</span><span style="color: #000000; font-weight: bold;">&gt;</span> sqlldr <span style="color: #007800;">userid</span>=loader<span style="color: #000000; font-weight: bold;">/</span>loader <span style="color: #007800;">control</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>loader.ctl <span style="color: #007800;">log</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>loader.log</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://sysinfo.bascomp.org/2007/10/sqlloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
