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

后端 未结 3 1948
野趣味
野趣味 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:07

    Use the same approach, but create a volatile table in the middle.

    CREATE VOLATILE MULTISET TABLE TEMPDB.TEMP_DUP_ID (
    Row_ID DECIMAL(31,0) ) PRIMARY INDEX (Row_ID) ON COMMIT PRESERVE ROWS;

    INSERT INTO TEMPDB.TEMP_DUP_ID SELECT ROW_ID FROM DB.TABLE T QUALIFY ROW_NUMBER() OVER (PARTITION BY DUP ORDER BY DUP DESC) > 1

    Then use the table to delete.

    Ideally you will have unique key per row, otherwise, you will need to manipulate the data a bit more to generate one (with row_number() for instance... This is just a recommendation).

提交回复
热议问题