DivyaTalluri
DivyaTalluri

Reputation: 87

How to change data base schema

I am using sqlite older version for developing my application.

For some problem i have altered one of the table for adding new column. Previously this table data is stored in integers, after altering the table they have changed to strings. How can I get the altered string data again to integers, while querying how to query these fields?

Upvotes: 9

Views: 12272

Answers (2)

user6194332
user6194332

Reputation: 1

Connect to your SQL lite database from visual studio server explorer and make schema changes from there. There is a edit schema option when you right click on the table you want to make changes.

Upvotes: 0

Donal Fellows
Donal Fellows

Reputation: 137757

SQLite only allows very limited changes to be done to an existing table. For anything else, you should:

  1. rename the old table,
  2. make a new table with the old name and with the correct column definitions,
  3. copy the data over, and
  4. drop the old table.

Do this within a single transaction, of course! Also, practice on another database before trying this with your production data.

Upvotes: 21

Related Questions