sqlite insert a new colum

https://stackoverflow.com/questions/4253804/insert-new-column-into-table-in-sqlite

1

ALTER TABLE {tableName} ADD COLUMN COLNew {type};

2

ALTER TABLE {tableName} RENAME TO TempOldTable;
CREATE TABLE {tableName} (name TEXT, COLNew {type} DEFAULT {defaultValue}, qty INTEGER, rate REAL);
INSERT INTO {tableName} (name, qty, rate) SELECT name, qty, rate FROM TempOldTable;
DROP TABLE TempOldTable;

你可能感兴趣的:(sqlite insert a new colum)