SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows these alterations of an existing table: it can be renamed; a column can be renamed; a column can be added to it; or a column can be dropped from it.
Summary. Use the ALTER TABLE statement to modify the structure of an existing table. Use ALTER TABLE table_name RENAME TO new_name statement to rename a table. Use ALTER TABLE table_name ADD COLUMN column_definition statement to add a column to a table.
In SQLite, you can not use the ALTER TABLE statement to drop a primary key. Instead, you must create a new table with the primary key removed and copy the data into this new table.
SQLite doesn't support removing or modifying columns, apparently. But do remember that column data types aren't rigid in SQLite, either.
See also:
If you prefer a GUI, DB Browser for SQLite will do this with a few clicks.
DB Browser for SQLite is open source and free. For Linux it is available from the repository.
It is possible by recreating table.Its work for me please follow following step:
do all above steps in worker thread to reduce load on uithread
There is a much simpler way:
ALTER TABLE your_main_table ADD COLUMN new_column_name new_column_data_type
UPDATE your_main_table SET new_column_name = CAST(old_column_name as new_data_type_you_want)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With