PostgreSQL function for last inserted ID

后端 未结 11 1353

In PostgreSQL, how do I get the last id inserted into a table?

In MS SQL there is SCOPE_IDENTITY().

Please do not advise me to use something like this:

11条回答
  •  一生所求
    2020-11-22 14:34

    See the RETURNING clause of the INSERT statement. Basically, the INSERT doubles as a query and gives you back the value that was inserted.

提交回复
热议问题