本文翻译自:PostgreSQL function for last inserted ID
In PostgreSQL, how do I get the last id inserted into a table? 在PostgreSQL中,如何将最后一个id插入表中?
In MS SQL there is SCOPE_IDENTITY(). 在MS SQL中有SCOPE_IDENTITY()。
Please do not advise me to use something like this: 请不要建议我使用这样的东西:
select max(id) from table
#1楼
参考:https://stackoom.com/question/clWF/PostgreSQL函数用于最后插入的ID
#2楼
you can use RETURNING clause in INSERT statement,just like the following 您可以在INSERT语句中使用RETURNING子句,如下所示
wgzhao=