SQL - Inserting a row and returning primary key

前端 未结 8 1170
南笙
南笙 2020-12-01 18:07

I have a little witty problem. Say, I inserted a row with some data in a table where a primary key is present. How would one \"SELECT\" the primary key of the row one just i

8条回答
  •  孤城傲影
    2020-12-01 18:20

    For Postgresql:

    SELECT CURRVAL(pg_get_serial_sequence('schema.table','id'))
    

    Source: https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id

提交回复
热议问题