 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How to insert multiple rows with a single INSERT in Oracle?</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2013 13:28:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: MTidmarsh</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-111169</link>
		<dc:creator>MTidmarsh</dc:creator>
		<pubDate>Mon, 17 Sep 2012 13:47:56 +0000</pubDate>
		<guid isPermaLink="false">#comment-111169</guid>
		<description><![CDATA[Looking for more information? See how you can &lt;a href=&quot;http://itknowledgeexchange.techtarget.com/itanswers/inserting-multiple-rows-in-oracle-10g/?=lpo&quot; rel=&quot;nofollow&quot;&gt;insert multiple rows in Oracle 10g&lt;/a&gt;. &lt;br&gt;]]></description>
		<content:encoded><![CDATA[<p>Looking for more information? See how you can <a href="http://itknowledgeexchange.techtarget.com/itanswers/inserting-multiple-rows-in-oracle-10g/?=lpo" rel="nofollow">insert multiple rows in Oracle 10g</a>. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amitbhumca</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-94540</link>
		<dc:creator>amitbhumca</dc:creator>
		<pubDate>Sat, 23 Jul 2011 04:39:21 +0000</pubDate>
		<guid isPermaLink="false">#comment-94540</guid>
		<description><![CDATA[&lt;b&gt;You can insert multiple rows using the following syntax:

       &lt;code&gt;INSERT ALL
       INTO mytable (column1, column2, column3) VALUES (&#039;val1.1&#039;, &#039;val1.2&#039;, &#039;val1.3&#039;)
       INTO mytable (column1, column2, column3) VALUES (&#039;val2.1&#039;, &#039;val2.2&#039;, &#039;val2.3&#039;)
       INTO mytable (column1, column2, column3) VALUES (&#039;val3.1&#039;, &#039;val3.2&#039;, &#039;val3.3&#039;)
    SELECT * FROM dual;&lt;/code&gt;

this command can insert multiple values in a single step. You can also insert multiple values in multiple tables by using this command.
e.g. 

&lt;code&gt;INSERT ALL
   INTO product (product_id,product_name) VALUES (1000, &#039;Disc&#039;)
   INTO product (product_id, product_name) VALUES (2000, &#039;Floppy&#039;)
   INTO customers (customer_id, customer_name, city) VALUES (999999, &#039;Anderson Construction&#039;, &#039;New York&#039;)
SELECT * FROM dual;&lt;/code&gt;&lt;/b&gt;]]></description>
		<content:encoded><![CDATA[<p><b>You can insert multiple rows using the following syntax:</p>
<p>       <code>INSERT ALL<br />
       INTO mytable (column1, column2, column3) VALUES ('val1.1', 'val1.2', 'val1.3')<br />
       INTO mytable (column1, column2, column3) VALUES ('val2.1', 'val2.2', 'val2.3')<br />
       INTO mytable (column1, column2, column3) VALUES ('val3.1', 'val3.2', 'val3.3')<br />
    SELECT * FROM dual;</code></p>
<p>this command can insert multiple values in a single step. You can also insert multiple values in multiple tables by using this command.<br />
e.g. </p>
<p><code>INSERT ALL<br />
   INTO product (product_id,product_name) VALUES (1000, 'Disc')<br />
   INTO product (product_id, product_name) VALUES (2000, 'Floppy')<br />
   INTO customers (customer_id, customer_name, city) VALUES (999999, 'Anderson Construction', 'New York')<br />
SELECT * FROM dual;</code></b></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rajpavan54</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-92945</link>
		<dc:creator>rajpavan54</dc:creator>
		<pubDate>Sat, 04 Jun 2011 05:12:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-92945</guid>
		<description><![CDATA[Answer for the above query is

&lt;code&gt;INSERT INTO  TABLE_NAME (column_name1,column_name2,column_name3.......) values (&amp;column_name1,&amp;column_name2,........);&lt;/code&gt;

Example:-
&lt;code&gt;create table KRP (ename varchar2(20),contact number(10));
Table create
insert into krp (ename,contact) values (&#039;&amp;ename&#039;,&amp;contact);&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>Answer for the above query is</p>
<p><code>INSERT INTO  TABLE_NAME (column_name1,column_name2,column_name3.......) values (&amp;column_name1,&amp;column_name2,........);</code></p>
<p>Example:-<br />
<code>create table KRP (ename varchar2(20),contact number(10));<br />
Table create<br />
insert into krp (ename,contact) values ('&amp;ename',&amp;contact);</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rajpavan54</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-92917</link>
		<dc:creator>rajpavan54</dc:creator>
		<pubDate>Fri, 03 Jun 2011 14:05:06 +0000</pubDate>
		<guid isPermaLink="false">#comment-92917</guid>
		<description><![CDATA[hi FrankKulash,
How is ‘&amp;’ used to insert multiples values on 10g?
can u explain clear with examples.]]></description>
		<content:encoded><![CDATA[<p>hi FrankKulash,<br />
How is ‘&amp;’ used to insert multiples values on 10g?<br />
can u explain clear with examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-89035</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Mon, 07 Mar 2011 14:21:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-89035</guid>
		<description><![CDATA[Vinayprasanna:

How is &#039;&amp;&#039; used to insert multiples values on 9i ?
Also, what exactly do you mean by &#039;multiple values&#039; (the original question was about multiple &#039;rows&#039;) ?]]></description>
		<content:encoded><![CDATA[<p>Vinayprasanna:</p>
<p>How is &#8216;&amp;&#8217; used to insert multiples values on 9i ?<br />
Also, what exactly do you mean by &#8216;multiple values&#8217; (the original question was about multiple &#8216;rows&#8217;) ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vinayprasanna</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-89010</link>
		<dc:creator>vinayprasanna</dc:creator>
		<pubDate>Sat, 05 Mar 2011 15:36:01 +0000</pubDate>
		<guid isPermaLink="false">#comment-89010</guid>
		<description><![CDATA[in oracle 9i &amp; is used to insert multiple values in a single table in that way is there any provision in oracle 10g for inserting multiple values in sql prompt]]></description>
		<content:encoded><![CDATA[<p>in oracle 9i &amp; is used to insert multiple values in a single table in that way is there any provision in oracle 10g for inserting multiple values in sql prompt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: frankkulash</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-51304</link>
		<dc:creator>frankkulash</dc:creator>
		<pubDate>Mon, 28 Jan 2008 19:57:07 +0000</pubDate>
		<guid isPermaLink="false">#comment-51304</guid>
		<description><![CDATA[Hi, again,

My previous message got truncated when I used a less-than sign.  I&#039;ll try it again, using ampersand-lt-semicolon.

The last line of the previous statement should read:

&lt;pre&gt;
WHERE	ROWNUM	&lt;= 5;
&lt;/pre&gt;

Notice that this statement is much harder to read and much longer than using five separate INSERT statements.  You can decide which is better to use in your application.

If there are patterns in the data (such as dt in this example, which is the firt day of five consecutive months), you can shorten the code, for instance:

&lt;pre&gt;
INSERT INTO table_x (id, dt, name)
SELECT	ROWNUM + 200
,	ADD_MONTHS	( TO_DATE (&#039;01-Dec-2007&#039;, &#039;DD-Mon-YYYY&#039;)
			, ROWNUM
			)
,	CASE	ROWNUM
		WHEN	1	THEN	&#039;Aardvark&#039;
		WHEN	2	THEN	&#039;Bass&#039;
		WHEN	3	THEN	&#039;Cedusa&#039;
		WHEN	4	THEN	&#039;Dodo&#039;
		WHEN	5	THEN	&#039;E. Coli&#039;
	END
FROM	all_views
WHERE	ROWNUM	&lt;= 5;
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>Hi, again,</p>
<p>My previous message got truncated when I used a less-than sign.  I&#8217;ll try it again, using ampersand-lt-semicolon.</p>
<p>The last line of the previous statement should read:</p>
<pre>
WHERE	ROWNUM	&lt;= 5;
</pre>
<p>Notice that this statement is much harder to read and much longer than using five separate INSERT statements.  You can decide which is better to use in your application.</p>
<p>If there are patterns in the data (such as dt in this example, which is the firt day of five consecutive months), you can shorten the code, for instance:</p>
<pre>
INSERT INTO table_x (id, dt, name)
SELECT	ROWNUM + 200
,	ADD_MONTHS	( TO_DATE ('01-Dec-2007', 'DD-Mon-YYYY')
			, ROWNUM
			)
,	CASE	ROWNUM
		WHEN	1	THEN	'Aardvark'
		WHEN	2	THEN	'Bass'
		WHEN	3	THEN	'Cedusa'
		WHEN	4	THEN	'Dodo'
		WHEN	5	THEN	'E. Coli'
	END
FROM	all_views
WHERE	ROWNUM	&lt;= 5;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: frankkulash</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-insert-multiple-rows-with-a-single-insert-in-oracle/#comment-51303</link>
		<dc:creator>frankkulash</dc:creator>
		<pubDate>Mon, 28 Jan 2008 19:48:43 +0000</pubDate>
		<guid isPermaLink="false">#comment-51303</guid>
		<description><![CDATA[Hi, Suresh,

The form of a multi-row INSERT is

&lt;pre&gt;
INSERT INTO table_name (column_1, column_2, ..., column_n)
SELECT value_1, value_2, ..., value_n
FROM ...
&lt;/pre&gt;

If the values don&#039;t actually exist in any table, you can SELECT them as literals from any table or view, such as dual or one of the data dictionary views.  (The view all_views is handy because everyone can SELECT from it, and it has hundreds of rows.)  The pseudo column ROWNUM is n for the nth row selected, and you can map this to your values using CASE (as shown below) or DECODE.

For example, say you want to INSERT this data into table_x:

&lt;pre&gt;
        ID DT          NAME
---------- ----------- --------------------
       201 01-Jan-2008 Aardvark
       202 01-Feb-2008 Bass
       203 01-Mar-2008 Cedusa
       204 01-Apr-2008 Dodo
       205 01-May-2008 E. Coli
&lt;/pre&gt;

Here&#039;s how you can INSERT it in a single SQL statement:

&lt;pre&gt;
INSERT INTO table_x (id, dt, name)
SELECT	CASE	ROWNUM
		WHEN	1	THEN	201
		WHEN	2	THEN	202
		WHEN	3	THEN	203
		WHEN	4	THEN	204
		WHEN	5	THEN	205
	END
,	TO_DATE	( CASE	ROWNUM
			WHEN	1	THEN	&#039;01-Jan-2008&#039;
			WHEN	2	THEN	&#039;01-Feb-2008&#039;
			WHEN	3	THEN	&#039;01-Mar-2008&#039;
			WHEN	4	THEN	&#039;01-Apr-2008&#039;
			WHEN	5	THEN	&#039;01-May-2008&#039;
		  END
		, &#039;DD-Mon-YYYY&#039;
		)
,	CASE	ROWNUM
		WHEN	1	THEN	&#039;Aardvark&#039;
		WHEN	2	THEN	&#039;Bass&#039;
		WHEN	3	THEN	&#039;Cedusa&#039;
		WHEN	4	THEN	&#039;Dodo&#039;
		WHEN	5	THEN	&#039;E. Coli&#039;
	END
FROM	all_views
WHERE	ROWNUM	&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>Hi, Suresh,</p>
<p>The form of a multi-row INSERT is</p>
<pre>
INSERT INTO table_name (column_1, column_2, ..., column_n)
SELECT value_1, value_2, ..., value_n
FROM ...
</pre>
<p>If the values don&#8217;t actually exist in any table, you can SELECT them as literals from any table or view, such as dual or one of the data dictionary views.  (The view all_views is handy because everyone can SELECT from it, and it has hundreds of rows.)  The pseudo column ROWNUM is n for the nth row selected, and you can map this to your values using CASE (as shown below) or DECODE.</p>
<p>For example, say you want to INSERT this data into table_x:</p>
<pre>
        ID DT          NAME
---------- ----------- --------------------
       201 01-Jan-2008 Aardvark
       202 01-Feb-2008 Bass
       203 01-Mar-2008 Cedusa
       204 01-Apr-2008 Dodo
       205 01-May-2008 E. Coli
</pre>
<p>Here&#8217;s how you can INSERT it in a single SQL statement:</p>
<pre>
INSERT INTO table_x (id, dt, name)
SELECT	CASE	ROWNUM
		WHEN	1	THEN	201
		WHEN	2	THEN	202
		WHEN	3	THEN	203
		WHEN	4	THEN	204
		WHEN	5	THEN	205
	END
,	TO_DATE	( CASE	ROWNUM
			WHEN	1	THEN	'01-Jan-2008'
			WHEN	2	THEN	'01-Feb-2008'
			WHEN	3	THEN	'01-Mar-2008'
			WHEN	4	THEN	'01-Apr-2008'
			WHEN	5	THEN	'01-May-2008'
		  END
		, 'DD-Mon-YYYY'
		)
,	CASE	ROWNUM
		WHEN	1	THEN	'Aardvark'
		WHEN	2	THEN	'Bass'
		WHEN	3	THEN	'Cedusa'
		WHEN	4	THEN	'Dodo'
		WHEN	5	THEN	'E. Coli'
	END
FROM	all_views
WHERE	ROWNUM	</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.039 seconds using memcached
Object Caching 365/371 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-25 14:53:02 -->