要通过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;
需要注意的是,在执行删除操作之前,建议先备份数据,以免误操作导致数据丢失。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: datagrip sql支持哪些数据库类型