Welcome to Dream.In.Code
Getting Help is Easy!

Join 105,763 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,664 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Duplicate Record Issue

 
Reply to this topicStart new topic

Duplicate Record Issue, Oracle

jjsaw5
post 9 May, 2008 - 11:58 AM
Post #1


D.I.C. Face

Group Icon
Joined: 4 Jan, 2008
Posts: 918



Thanked 5 times

Dream Kudos: 125
My Contributions


Alright so I have run into a little issue. Some how I got a duplicate record into one of my Oracle tables.

Is it possible to alter one of the duplicate fields? Or will I have to delete them?


User is online!Profile CardPM

Go to the top of the page


Nykc
post 9 May, 2008 - 12:43 PM
Post #2


I has D.I.C

Group Icon
Joined: 14 Sep, 2007
Posts: 2,874



Thanked 5 times

Dream Kudos: 250
My Contributions


If it is just an entry why don't you just delete the duplicate record? Are you sure there is not a punctuation or mispelling of one of them?
User is online!Profile CardPM

Go to the top of the page

jayman9
post 9 May, 2008 - 12:48 PM
Post #3


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,241



Thanked 21 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


If you had a primary key in your table this would have never happened.

You are just going to have to delete the duplicate records. You cannot change one of the records because they are duplicates. Any type of alteration will result in both of them being changed, so they will always be duplicate.
User is offlineProfile CardPM

Go to the top of the page

baavgai
post 9 May, 2008 - 01:36 PM
Post #4


Dreaming Coder

Group Icon
Joined: 16 Oct, 2007
Posts: 1,471



Thanked 38 times

Dream Kudos: 325

Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions


QUOTE(jjsaw5 @ 9 May, 2008 - 02:58 PM) *

Is it possible to alter one of the duplicate fields? Or will I have to delete them?


Depends on how you want to alter them. You can grab one of the dups, and then change those that follow based on something that makes sense in the table. However, if the rows are identical, you might as well just delete them, as such extra rows would simply have no meaning in any context.

Something like this would get you what you want to keep:
CODE

create table foo as select distinct * from table1;
delete table1;
insert into table1 select * from foo;
drop table foo;


Hope this helps.
User is online!Profile CardPM

Go to the top of the page

jjsaw5
post 12 May, 2008 - 05:11 AM
Post #5


D.I.C. Face

Group Icon
Joined: 4 Jan, 2008
Posts: 918



Thanked 5 times

Dream Kudos: 125
My Contributions


I'll delete the records it seems to be the easiest thing, and in the course of trying to fix this issue i found a couple other ones that i will need to address as well.


Thank you for the suggestions!
User is online!Profile CardPM

Go to the top of the page

1lacca
post 12 May, 2008 - 10:19 AM
Post #6


code.rascal

Group Icon
Joined: 11 Aug, 2005
Posts: 3,666



Thanked 9 times
My Contributions


QUOTE(jayman9 @ 9 May, 2008 - 09:48 PM) *

Any type of alteration will result in both of them being changed, so they will always be duplicate.

In Oracle there is a column called rowid, it can be used to alter individual records, but I'm not sure if it worth the effort.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 01:56PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month