How to insert duplicate rows in SQLite with a unique ID?

后端 未结 4 710
半阙折子戏
半阙折子戏 2021-02-05 16:16

This seems simple enough: I want to duplicate a row in a SQLite table:

INSERT INTO table SELECT * FROM table WHERE rowId=5;

If there were no ex

4条回答
  •  心在旅途
    2021-02-05 16:29

    Well, since I was unable to do this the way I wanted, I resorted to using the implicit row id, which handily enough has the same name as the rowId column I defined explicitly, so now I can use the query I had in the question, and it will insert all the data with a new rowId. To keep the rest of the program working, I just changed SELECT * FROM table to SELECT rowId,* FROM table and everything's fine.

提交回复
热议问题