如何使用DB2限制DELETE中的行数? [英] How do I LIMIT the number of rows in a DELETE with DB2?

查看:712
本文介绍了如何使用DB2限制DELETE中的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想模仿MySQL允许您的方式,我想在敏感表上添加一个安全性。限制在SQL请求中删除的行数。



基本上我想用DB2执行此操作:

  DELETE FROM table WHERE info ='1'LIMIT 1 

有没有办法使用DB2?

解决方案

 从表中删除id (select id from table where info ='1'order by id fetch first 1 rows only)


I want to add a security on a sensitive table when I delete lines with an SQL request on a DB2 table.

I want to mimic the way MySQL allows you to limit the numbers of rows deleted in an SQL request.

Basically I want to do this with DB2 :

DELETE FROM table WHERE info = '1' LIMIT 1

Is there a way to do that with DB2 ?

解决方案

delete from table where id in (select id from table where info = '1' order by id fetch first 1 rows only)

这篇关于如何使用DB2限制DELETE中的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆