Home » RDBMS Server » Server Administration » insertion.. How can we make multiple insertion in a table?? PLZ HELP
insertion.. How can we make multiple insertion in a table?? PLZ HELP [message #371375] Tue, 10 October 2000 22:51 Go to next message
bassiouni
Messages: 4
Registered: October 2000
Junior Member
How can we make multiple insertion in a table?? PLZ HELP
Re: insertion.. How can we make multiple insertion in a table?? PLZ HELP [message #371378 is a reply to message #371375] Wed, 11 October 2000 03:15 Go to previous messageGo to next message
Sandeep Deshmukh
Messages: 13
Registered: October 2000
Junior Member
Bassiouni,

Through SQL you can have multiple rows insertion possible only through use of output of select query. The syntax would look like.
1) insert into table1
( select * from table2)
2)insert into table1 (col1,col2..coln)
(select col1,col2...coln from table2[[,table3]]

1. In both the cases "not null"columns in table1 should be populated through select.
2. You can have all rows inserted in a table which are brough as o/p of select.
3. If you are using values clause of insert i.e. insert into table1 values (..) ,u can't have more than a row at a time

Hope this helps.

Regards,
Sandeep

Regards,
Sandeep
Re: insertion.. How can we make multiple insertion in a table?? PLZ HELP [message #371382 is a reply to message #371378] Wed, 11 October 2000 13:28 Go to previous messageGo to next message
bassiouni
Messages: 4
Registered: October 2000
Junior Member
thank you... that is what i wanted to know... i was hoping that there was a faster way to insert values(not coming from a query, or a table..but introduced by the user) instead of using the insert into methode..
but there must be a quicker way... [message #371383 is a reply to message #371378] Wed, 11 October 2000 13:30 Go to previous messageGo to next message
bassiouni
Messages: 4
Registered: October 2000
Junior Member
when you have to enter 100 lines in a table, do you have to type 100 times insert into???? that wont be very fast...
Re: but there must be a quicker way... [message #371385 is a reply to message #371378] Wed, 11 October 2000 23:42 Go to previous message
Sandeep Deshmukh
Messages: 13
Registered: October 2000
Junior Member
bassiouni,

Yeah theres a way,if you wan't not to type "insert into" for n times for n rows.On sql prompt,u use -

insert into table1 (col1...coln)
values
(&1,'&2',&3.... &n)
/

It will ask you for values 1 ..n for first row.And after / ,you can enter it for next set.
This way you just need to enter valuez not the syntax again & again.
There is a variant of the substitution variable(&) in form of && where in you need to give value only once & next time onward it will use the same value in the insert column(unless you change it with define).SO the combination of & and && will make the insertion easy for you.

But I will suggest ,if you got a requirement of bulk insertion.You better go for SQLLOAD with append option.
Previous Topic: Re: Stored Procedure
Next Topic: How to check cursor is open or not in PRO*C
Goto Forum:
  


Current Time: Sun Dec 22 15:11:12 CST 2024