Answers

Question and Answer:

  Home  Sybase

⟩ Given a table which contains some rows with duplicate keys, how would you remove the duplicates?

create temporary table with same table structure and then create unique index on this temporary table with option ignore_dup_row.

now insert data into temp table from the table in which duplicate records exists.

while inserting record into temp table, duplicate rows will get ingored.

Finally temp table will have unique records

Ex:

select distinct * from table_1 into temp_table_1

truncate table_1

insert into table_1

select * from temp_table_1

This is one of the ways to eliminate duplicates.

 195 views

More Questions for you: