Skip to content

Instantly share code, notes, and snippets.

@finsterthecat
Created February 22, 2011 18:23
Show Gist options
  • Select an option

  • Save finsterthecat/839106 to your computer and use it in GitHub Desktop.

Select an option

Save finsterthecat/839106 to your computer and use it in GitHub Desktop.
Fix duplicates. Useful for when you want to add an alternate key to fields that currently have dups.
update searchable s1
set datasource_guid = datasource_guid || ' @@DUPLICATE@@ ' || searchable_id,
published_flag = 'N'
where s1.searchable_id >
(
select min(s2.searchable_id)
from searchable s2
where s1.datasource_id = s2.datasource_id
and s1.datasource_guid = s2.datasource_guid
);
@finsterthecat
Copy link
Author

Somewhat inspired by http://www.adp-gmbh.ch/ora/sql/delete_dups.html . But not as good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment