andrefadila
andrefadila

Reputation: 687

Cannot delete column from sqlite table [Android]

Since I cannot comment here : How do I delete column from sqlite table in android?

I do the method and not work at all, the column is still exist. Here's my SQL :

db.execSQL("CREATE TEMPORARY TABLE Evaluation_backup(" + allColumnName + ");" 
                    + "INSERT INTO Evaluation_backup SELECT " + allColumnName + " FROM Evaluation;"
                    + "DROP TABLE Evaluation;" 
                    + "CREATE TABLE Evaluation("+ allColumnName + ");" 
                    + "INSERT INTO Evaluation SELECT " + allColumnName + " FROM Evaluation_backup;"
                    + "DROP TABLE Evaluation_backup;");

The allColumnName is String contains all the column names except the name of the column that I want to remove. The allColumnName content like this: column1,column2,column3.

Thanks in advance.

Upvotes: 4

Views: 1697

Answers (1)

CL.
CL.

Reputation: 180210

The documentation for execSql says:

Execute a single SQL statement …

Call db.execSql once for each statement.

Upvotes: 6

Related Questions