I have a table with columns name
, qty
, rate
. Now I need to add a new column COLNew
in between the name
and qty
columns. How do I add a new column in between two columns?
Sqlite – Insert new column into table in sqlite
sqlite
Related Topic
- Sqlite – How to rename a column in a SQLite database table
- Sqlite – How to get a list of column names on Sqlite3 database
- Sqlite – How to check in SQLite whether a table exists
- Sqlite – Improve INSERT-per-second performance of SQLite
- SQLite table constraint – unique on multiple columns
- Sqlite – INSERT IF NOT EXISTS ELSE UPDATE
- Sqlite – How to concatenate strings with padding in sqlite
- Sqlite alter table add MULTIPLE columns in a single statement
Best Answer
You have two options. First, you could simply add a new column with the following:
Second, and more complicatedly, but would actually put the column where you want it, would be to rename the table:
Then create the new table with the missing column:
And populate it with the old data:
Then delete the old table:
I'd much prefer the second option, as it will allow you to completely rename everything if need be.