SQL - INSERT and catch the id auto-increment value

前端 未结 7 966
梦毁少年i
梦毁少年i 2020-12-05 19:26

What is the best way to get the auto-id value in the same SQL with a SELECT?

A forum said adding this \"; has Return Scope_Identity()\"
in the end

7条回答
  •  无人及你
    2020-12-05 19:53

    Be very careful: Apparently select nextval(seq) does not work in high concurrency - some other connection can insert between the time when you inserted and the time when you called select nextval(seq). Always test such code in high concurrency test harnesses.

提交回复
热议问题