How to Delete Duplicate Records in Oracle
Method 1 of 4:
Identifying your Duplicate
- 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.
- Identifying from a column named "Names." In the instance of a column named "Names," you would replace "column_name" with Names.
- 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.
select column_name, count(column_name) from table group by column_name having count (column_name) > 1;
Method 2 of 4:
Deleting a Single Duplicate
- Select "name from names." After "SQL," which stands for Standard Query Language, enter "select name from names."
- 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]
- 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.
- 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."
SQL > select name from names; NAME ------------------------------ Alan Carrie Tom Alan rows selected. SQL > delete from names where name='Alan'; rows deleted. SQL > commit; Commit complete. SQL > insert into names values ('Alan'); row created. SQL > commit; Commit complete. SQL > select * from names; NAME ------------------------------ Alan Carrie Tom rows selected.
Method 3 of 4:
Deleting Multiple Duplicates
- Select the RowID you want to delete. After "SQL," enter "select rowid, name from names;."
- Delete the duplicate. After "SQL," enter "delete from names a where rowid > (select min(rowid) from names b where b.name=a.name);" to delete duplicate records.[2]
- Check for duplicates. After you have completed the above, commands check to see if you still have duplicate records by entering "select rowid,name from names;" and then "commit."
SQL > select rowid,name from names; ROWID NAME ------------------ ------------------------------ AABJnsAAGAAAdfOAAA Alan AABJnsAAGAAAdfOAAB Alan AABJnsAAGAAAdfOAAC Carrie AABJnsAAGAAAdfOAAD Tom AABJnsAAGAAAdfOAAF Alan rows selected. SQL > delete from names a where rowid > (select min(rowid) from names b where b.name=a.name ); rows deleted. SQL > select rowid,name from names; ROWID NAME ------------------ ------------------------------ AABJnsAAGAAAdfOAAA Alan AABJnsAAGAAAdfOAAC Carrie AABJnsAAGAAAdfOAAD Tom rows selected. SQL > commit; Commit complete.
Method 4 of 4:
Deleting Rows with Columns
- Select your rows. After "SQL," enter "select * from names;" to see your rows.
- 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]
- 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.
SQL > select * from names; NAME AGE ------------------------------ ---------- Alan 50 Carrie 51 Tom 52 Alan 50 rows selected. SQL > delete from names a where rowid > (select min(rowid) from names b where b.name=a.name and b.age=a.age ); row deleted. SQL > select * from names; NAME AGE ------------------------------ ---------- Alan 50 Carrie 51 Tom 52 rows selected. SQL > commit; Commit complete.
4.3 ★ | 12 Vote
You should read it
- Facebook name or best Facebook name combination
- How to find names in Excel
- How to arrange names in alphabetical order in Word
- 1000 beautiful girls names for you to choose for your little princess
- How to Change File Names in Bulk on PC or Mac
- How to create AutoFill strings in Excel
- Why do storms around the world often have women's names?
- 50 best boys should choose to set for 'little prince'
May be interested
- How to delete duplicate app icons on Androidthe application icon helps visually distinguish the application so that it can be opened quickly when needed. some android users are having the problem of duplicate icons on the home screen and app drawer.
- Find and delete duplicate data in Excelfind and delete duplicate data in excel. in the process of working with excel spreadsheets, there will be excel files with large amounts of data so duplication of data is very common. there are cases where duplicate data is useful, but sometimes values are
- (Giveaway) Install Duplicate Cleaner for Mac license, delete duplicate files from August 8duplicate cleaner for mac application supports finding and removing duplicate files in the system, helping to free up computer memory.
- DELETE command in SQL Serverthe delete statement in sql server (transact-sql) is used to delete one or more records from a table in sql server.
- 2 ways to delete data, duplicate content in Excelsometimes when working with data on excel, you encounter cases where the data content is duplicated between large amounts of data.
- How to remove duplicates in excelto delete the same lines and figures in excel data sheet, we can use available features like remove duplicate or manually delete through the hightlight section.
- Guide to find and delete duplicate photos in your computer using the Duplicate Images Findersometimes in the process of data storage it is very likely that you save the same data file in different locations. the following article details how to find duplicate photos on your computer.
- Filter duplicate data, delete duplicate data in Excelfor excel files with large log volumes, duplication of data is very common. so i introduce to you how to filter duplicated data with tools available in excel.
- How to delete duplicate photos, the same photo on Android phonesafter a long time of use, our phones will have a lot of duplicate photos from applications, downloads, screenshots, ... they will consume a lot of space on our memory. if we manually filter and delete, it will take a lot of time and even take photos.
- What is Oracle VirtualBox? What can be done with it?to create these virtual machines, we use a program called hypervisor. one of the most recommended hypervisors is oracle's virtualbox.