删除某个表中的前1000条记录的SQL语句怎么写

2025-03-23 06:55:54
推荐回答(2个)
回答1:

delete from 表名称 where rownum<=1000;

回答2:

1: 简单的 top方式
delete from 表 where id in(select top 3 id from 表)
2:rank排名函数
根据某些业务条件,使用排名函数获得排名靠前的值,再使用删除操作
deletefrom 表 where id in(
select id from(
SELECT id ,RANK() OVER (PARTITION BY i. i.Quantity DESC) AS Rank
FROM表
) where rank<=3
)