androidsqliteprimary-key

rename a primary key in SQLite


My android application has a predefined database in the assets folder. Table WMExecutiveActivity has 5 primary keys. I want to rename one of them.

How do I rename a primary key in SQLite?

My attempt is not working:

ALTER TABLE WMExecutiveActivity
CHANGE CategoryCode ComplaintActivityCategory char( 4 )

Solution

  • According to the documentation (see here) it is not possible to change the table in that way.

    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.