InterviewSolution
| 1. |
How Do I Add Or Delete Columns From An Existing Table In Sqlite? |
|
Answer» SQLite has LIMITED ALTER TABLE support that you can use to add a column to the end of a table or to change the name of a table. If you want to MAKE more COMPLEX changes in the structure of a table, you will have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data BACK in from the temporary table. For example: suppose you have a table named "t1" with columns names "a", "b", and "c" and that you want to delete column "c" from this table. The following STEPS illustrate how this could be done: BEGIN TRANSACTION; SQLite has limited ALTER TABLE support that you can use to add a column to the end of a table or to change the name of a table. If you want to make more complex changes in the structure of a table, you will have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data back in from the temporary table. For example: suppose you have a table named "t1" with columns names "a", "b", and "c" and that you want to delete column "c" from this table. The following steps illustrate how this could be done: BEGIN TRANSACTION; |
|