3

I would like to add another column to a table in my existing SQLite database.

Is this possible, or is there something specific I need to do to upgrade it?

If so, how do I go about doing this?

3 Answers 3

10

Use the ALTER TABLE command:

ALTER TABLE my_table
    ADD COLUMN new_column;
Sign up to request clarification or add additional context in comments.

3 Comments

Where to i implement this at? in the createDatabse method? where i initially create the database?
You just execute that command in sqlite, same as any other SQL query.
If you extend SQLiteOpenHelper then I would recommend to use onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion).
5

Consider using an ALTER TABLE script this guide should give you all you need, http://www.sqlite.org/lang_altertable.html

Comments

1

Use the alter table clause See this

1 Comment

Can you provide an example of how to implement this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.