|
Here is an
interesting script I found on Metalink (Note:1019920.6) for removing duplicates, but I have not tried it yet: ====== Title: ====== Script to Eliminate Non-unique Rows =========== Disclaimer: =========== This script is provided for educational purposes only. It is NOT supported by Oracle World Wide Technical Support. The script has been tested and appears to work as intended. However, you should always test any script before relying on it. PROOFREAD THIS SCRIPT PRIOR TO USING IT! Due to differences in the way text editors, email packages and operating systems handle text formatting (spaces, tabs and carriage returns), this script may not be in an executable state when you first receive it. Check over the script to ensure that errors of this type are corrected. ========= Abstract: ========= This script removes all but one row (all but the row with the highest rowid) from <owner>.<table> in each group of rows having identical values in <column(s)>. Multiple columns must be separated with commas (without spaces). Script TFSUNIQU is intended primarily for use in deleting rows that prevent the creation of a unique index on the columns in <column(s)>. It will happily delete rows that are not identical, as long as the rows are identical with respect to the values of the columns in <column(s)>. ============= Requirements: ============= You must have DELETE privileges on the selected table. ======= Script: ======= ----------- cut ---------------------- cut -------------- cut -------------- SET ECHO off REM NAME: TFSUNIQU.SQL REM USAGE:"@path/tfsuniqu schema_name table_name column_name(s)" REM ------------------------------------------------------------------------ REM REQUIREMENTS: REM DELETE on selected table REM ------------------------------------------------------------------------ REM AUTHOR: REM Grant Franjione, Phil Joel, and Cary Millsap REM (c)1994 Oracle Corporation REM ------------------------------------------------------------------------ REM PURPOSE: REM Removes all but one row (all but the row with the highest rowid) REM from <owner>.<table> in each group of rows having identical values REM in <colum(s)>. Multiple columns must be seperated with commas REM (without spaces). REM REM TFSUNIQU is intended primarily for use in deleting rows that REM prevent the creation of a unique index on the columns in REM <column(s)>. It will happily delete rows that are not identical, REM as long as the rows are identical with respect to the values of REM the columns in <column(s)>. REM ------------------------------------------------------------------------ REM EXAMPLE: REM N/A REM ------------------------------------------------------------------------ REM DISCLAIMER: REM This script is provided for educational purposes only. It is NOT REM supported by Oracle World Wide Technical Support. REM The script has been tested and appears to work as intended. REM You should always run new scripts on a test instance initially. REM ------------------------------------------------------------------------ REM Main text of script follows: def owner = &&1 def table = &&2 def uukey = &&3 delete from &owner..&table where rowid in ( select rowid from &owner..&table minus select min(rowid) from &owner..&table group by &uukey ) / undef owner undef table undef uukey ----------- cut ---------------------- cut -------------- cut --------------
|
- Remove Duplicates Terrian, Tom
- Re: Remove Duplicates Rachel Carmichael
- Re: Remove Duplicates Stephane Faroult
- RE: Remove Duplicates Ferenc Mantfeld
- RE: Remove Duplicates Deshpande, Kirti
- Re: Remove Duplicates Stephane Faroult
- RE: Remove Duplicates Larry Elkins
- RE: Remove Duplicates David Wagoner
- RE: Remove Duplicates S B
- RE: Remove Duplicates Alex Hillman
