要通過Delete SQL刪除重復記錄,可以按照以下步驟進行操作:
SELECT column1, column2, COUNT(*)
FROM table_name
GROUP BY column1, column2
HAVING COUNT(*) > 1;
WITH CTE AS (
SELECT column1, column2,
ROW_NUMBER() OVER(PARTITION BY column1, column2 ORDER BY column1) AS RN
FROM table_name
)
DELETE FROM CTE
WHERE RN > 1;
需要注意的是,在執行刪除操作之前,建議先備份數據,以免誤操作導致數據丟失。