|
Oracle General Oracle database discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
January 6th, 2004, 03:43 PM
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
INSERT multiple rows to a table
Is there a way to insert multiple rows into a table in SQL without inserting one at a time like so:
INSERT INTO emp
VALUES(7698, 'Blake', 'Manager', 7839, '01-MAY-81', 2850, 30);
I want to insert multiple rows without having to re-type this row over and over again.
Thanks!
nvillare
__________________
Thanks!
N
|
January 7th, 2004, 07:45 AM
|
|
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Not unless you can formaulate the data to be inserted as a select statement:
Code:
INSERT INTO emp
(SELECT id, surname, jobtitle, manageriD... FROM tblWhatever...)
You may have to do two stages, put the data into a temporary table first then insert from that table afterwards.
--
Joe
|
January 27th, 2004, 04:17 AM
|
Registered User
|
|
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi there .....
you have to use this symbol & if u want to insert more than one record into your table , the idea is so easy .. just use the sign before the column aheader name ... and oracle will ask u to enter the value of that column .... if u want to execute the command again just reexecute it .
this is an example :
insert into emp(empno,ename,job,mgr) values (&empno,'&ename','&job',&mgr);
try it .................
bond james bond
|
March 9th, 2004, 01:21 AM
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
as far as I know, there is now way to do a looping in SQL to insert multiple record but you can use a simple PL/SQL to do that looping
|
September 13th, 2004, 09:12 PM
|
Registered User
|
|
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try:
Insert into TableX (Column1, Column2)
Select A, B
Union All
Select C, D
Regards,
Evbo
|
August 3rd, 2007, 11:48 AM
|
Registered User
|
|
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
INSERT INTO emp
select * from
(select 7698, 'Blake', 'Manager', 7839, '01-MAY-81', 2850, 30 from dual) union
(select 1235, 'Bob', 'Executive', 1235, '01-MAY-81', 2850, 30 from dual) union
(select 5465, 'Joe', 'Engineer', 5465, '01-MAY-81', 2850, 30 from dual);
|
September 4th, 2007, 12:34 AM
|
Registered User
|
|
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Table Name : MENU_SEASONS
Columns : F_CODE NUMBER(6),F_NAME CHAR(40 BYTE),F_RATE NUMBER(7)
insert statement for multiple rows.
INSERT INTO MENU_SEASONS
( SELECT 1005,'COMBINATIONS OF ARABIC MEEZE',14 FROM DUAL
UNION
SELECT 1006,'ICECREAMS',3 FROM DUAL
union
select 1007,'FROZEN YOGHURT',2 from dual
union
select 1008,'KABABS,SEAFOOD AND TANDOORI',16 from dual
union
select 1009,'ITALIAN BISTRO',14 from dual
union
select 1010,'AMERICAN PIZZA',20 from dual
union
select 1011,'B-B-Q CHICKEN',22 from dual
union
select 1012,'MEXICAN CHICKEN',18 from dual
union
select 1013,'BURGERS / GRILLS',8 from dual
union
select 1014,'ROAST BEEF/BURGERS',10 from dual
union
select 1015,'CHICKEN BURGERS',6 from dual
union
select 1016,'FLAME GRILLED CHICKEN',14 from dual
);
Chandralalprabu S,
Application Engineer,
Intergraph Middle East L L C,
Oman.
Cell:+96 892669479.
|
November 3rd, 2007, 04:47 AM
|
Authorized User
|
|
Join Date: Dec 2005
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Hi,
If you are uisig .net, then you can insert multiple records with the help of data adapter.
Surendra Parashar
Gurgaon, Hariyana
|
|
|