Can we delete duplicate records from a table in teradata without using intermediate table

后端 未结 3 1949
野趣味
野趣味 2020-12-12 04:48

Can we delete duplicate records from a multiset table in teradata without using intermediate table.

Suppose we have 2 rows with values 1, 2, 3 and 1, 2, 3 in my mu

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 05:31

    You can't unless the ROWID usage has been enabled on your system (and probablity is quite low). You can easily test it by trying to explain a SELECT ROWID FROM table;

    Otherwise there are two possible ways.

    Low number of duplicates:

    • create a new table as result of SELECT all columns FROM table GROUP BY all columns HAVING COUNT(*) > 1;
    • DELETE FROM tab WHERE EXISTS (SELECT * FROM newtab WHERE...)
    • INSERT INTO tab SELECT * FROM newtab

    High number of duplicates:

    • copy to a new table using SELECT DISTINCT * or copy to a SET TABLE to get rid of the duplicates and then re-INSERT back

提交回复
热议问题