When working in Oracle, you may find that some of your records have duplicates. You can delete these duplicate rows by identifying them and using its RowID, or row address. Before you begin, you should create a backup table in case you need to reference them after you have deleted records.

Steps

Method1

Identifying your Duplicate

1

Identify the duplicate. In this case, identify the example duplicate, "Alan." Make sure that the records you are trying to delete are actually duplicates by entering the SQL below.

2

Identifying from a column named "Names." In the instance of a column named "Names," you would replace "column_name" with Names.

3

Identifying from other columns. If you were trying to identify the duplicate by a different column, for example the age of Alan rather than his name, you would enter "Ages" in the place of "column_name" and so on.

Method2

Deleting a Single Duplicate

1

Select "name from names." After "SQL," which stands for Standard Query Language, enter "select name from names."

2

Delete all of the rows with the duplicate name. After "SQL," enter "delete from names where name='Alan';." Note that capitalization is important here, so this will delete all of the rows named "Alan." After "SQL," enter "commit."[1]

3

Renter the row without a duplicate. Now that you have deleted all rows with the example name "Alan," you can insert one back by entering "insert into name values ('Alan');." After "SQL," enter "commit" to create your new row.

4

See your new list. Once you have completed the above steps, you can check to make sure you no longer have duplicate records by entering "select * from names."

Method4

Deleting Rows with Columns

Delete duplicate rows by identifying their column. After "SQL'" enter "delete from names a where rowid > (select min(rowid) from names b where b.name=a.name and b.age=a.age);" to delete the duplicate records.[3]

3

Check for duplicates. Once you have completed the above steps, enter "select * from names;" and then "commit" in order to check that you have deleted the duplicate records successfully.