how to return last inserted (auto incremented) row id in HSQL?

旧街凉风 提交于 2019-11-28 13:47:18

It's pretty hard to write a query to perform this when you haven't given your table schema, but something like the following:

SELECT TOP 1 Id FROM [TABLENAME] ORDER BY Id DESC

http://www.hsqldb.org/doc/guide/ch09.html

the last inserted value into an identity column for a connection is available using the function IDENTITY(), for example (where Id is the identity column):

INSERT INTO Test (Id, Name) VALUES (NULL,'Test');
CALL IDENTITY();

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!