DB2如何从表中获取最后一个插入ID [英] DB2 how to get the last insert id from a table
本文介绍了DB2如何从表中获取最后一个插入ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取表中最后一个ID插入的值。我可以这样做吗?
解决方案
我使用的解决方案是:
$ pre>
从NEW TABLE(插入到(val1,val2,...)值('lorem','ipsum',...)中选择id
这将从DB中插入的最后一行获取id列:)
i want to get the value of the last id insert in a table. How i can do this?
解决方案
Well the solution that I use is:
select id from NEW TABLE (insert into (val1, val2, ...) values ('lorem', 'ipsum', ...))
This gets the id column from the last row inserted in the DB :)
这篇关于DB2如何从表中获取最后一个插入ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文