SQLite auto-increment non-primary key field

前端 未结 4 1278
醉话见心
醉话见心 2020-12-01 10:56

Is it possible to have a non-primary key to be auto-incremented with every insertion?

For example, I want to have a log, where every log entry has a primary key (for

4条回答
  •  执念已碎
    2020-12-01 11:22

    You could use a trigger (http://www.sqlite.org/lang_createtrigger.html) that checks the previous highest value and then increments it, or if you are doing your inserts through in a stored procedure, put that same logic in there.

提交回复
热议问题