Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to delete duplicate data in Oracle SQL?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 535
    Comment on it

    Let's create a table with duplicate rows in SQL.

    create table CustomerDuplicate(customer_id int,customer_name varchar(20))
    
    insert into CustomerDuplicate values(1,'Adam')
    insert into CustomerDuplicate values (1,'Adam')
    insert into CustomerDuplicate values(2,'Brags')
    insert into CustomerDuplicate values(2,'Brags')
    insert into CustomerDuplicate values (2,'Brags')
    insert into CustomerDuplicate values (3,'Cyrus')
    insert into CustomerDuplicate values (3,'Cyrus')
    insert into CustomerDuplicate values (4,'David')
    

    One of easiest way to delete the data is on the basis of column that repeat more than once.

    Example Query:

    delete from CustomerDuplicate where customer_id in(select customer_id from CustomerDuplicate group by customer_id having count(*) >1);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: