Can I alter a column in an sqlite table to AUTOINCREMENT after creation?

后端 未结 11 1793
野趣味
野趣味 2020-12-13 13:08

Can I make a field AUTOINCREMENT after made a table? For example, if you create a table like this:

create table person(id integer primary key, n         


        
11条回答
  •  囚心锁ツ
    2020-12-13 13:44

    Simplest way — Just export and re-import

    It is possible, and relatively easy. Export the database as an sql file. Alter the SQL file and re-import:

      sqlite3 mydata.db .dump > /tmp/backup.sql
      vi /tmp/backup.sql
      mv mydata.db mydata.db.old
      sqlite3 mydata.db
      sqlite>.read /tmp/backup.sql
    

提交回复
热议问题