Home » SQL & PL/SQL » SQL & PL/SQL » Insert rows with no duplicate
Insert rows with no duplicate [message #260330] Sat, 18 August 2007 09:13 Go to next message
jadoo83
Messages: 26
Registered: October 2006
Location: Mumbai
Junior Member
Hi,

How can i insert rows into a table with no duplicates records?

Thanks
Re: Insert rows with no duplicate [message #260331 is a reply to message #260330] Sat, 18 August 2007 09:19 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Quote:
insert rows into a table with no duplicates records
Inserting into a table?
 a) from a table?
(or)
 b) direct values?

If a), then use DISTINCT while selecting from the other table.
If b), then 1. do you want to raise error?
               then create an unique key on those columns.
By
Vamsi
Re: Insert rows with no duplicate [message #260332 is a reply to message #260331] Sat, 18 August 2007 09:24 Go to previous messageGo to next message
jadoo83
Messages: 26
Registered: October 2006
Location: Mumbai
Junior Member
In second case if there is no constraints in table then how can we insert data with no duplicate?
Re: Insert rows with no duplicate [message #260334 is a reply to message #260332] Sat, 18 August 2007 09:51 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
I don't think so.
But what is stopping you to create a constraint? I think the best way to get stopped by Oracle.

By the way in my previous post I have mentioned you can use DISTINCT, when you want to insert data from another table.
I was thinking that you were creating a new table.
DISTINCT also won't help when you insert data more than once.

By
Vamsi

[Updated on: Sat, 18 August 2007 09:52]

Report message to a moderator

Re: Insert rows with no duplicate [message #260367 is a reply to message #260334] Sun, 19 August 2007 02:28 Go to previous messageGo to next message
Dipali Vithalani
Messages: 278
Registered: March 2007
Location: India
Senior Member

If you are not willing to use the unique key constratint then you can also do that using an Before Instert Trigger.

But oracles states that, the unique key constraint is better solution than using Trigger to apply such constratints..

Regards..

Dipali
Re: Insert rows with no duplicate [message #260393 is a reply to message #260367] Sun, 19 August 2007 08:25 Go to previous message
jadoo83
Messages: 26
Registered: October 2006
Location: Mumbai
Junior Member
Thanks a lot for ur suggestions. I think putting unique key constraints is best solution.
Previous Topic: Sum through a hierarchy
Next Topic: How to Read CLOB
Goto Forum:
  


Current Time: Fri Dec 02 18:23:29 CST 2016

Total time taken to generate the page: 0.39454 seconds