要刪除重復數據,可以使用以下方法之一:
CREATE TABLE new_table AS
SELECT DISTINCT * FROM original_table;
DROP TABLE original_table;
ALTER TABLE new_table RENAME TO original_table;
WITH cte AS (
SELECT *, ROW_NUMBER() OVER (PARTITION BY column1, column2, ... ORDER BY column1) AS rn
FROM original_table
)
DELETE FROM cte WHERE rn > 1;
DELETE FROM original_table
WHERE (column1, column2, ...) IN (
SELECT column1, column2, ...
FROM original_table
GROUP BY column1, column2, ...
HAVING COUNT(*) > 1
);
以上方法需要根據具體的數據庫系統和表結構進行調整。在執行刪除操作之前,建議先備份數據以防止意外情況的發生。