4

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.

8
  • is your table created with these commands? Commented Aug 7, 2013 at 6:23
  • I have checked the string 'allColumnName'. My table still exist with the all column (I didn't knew the table was created or this SQL not worked). By the way, I have successfully added new column in the table. Commented Aug 7, 2013 at 6:30
  • What do you mean @d'alar'cop? Sorry I don't get it. Commented Aug 7, 2013 at 6:34
  • I speak rubbish - never mind. Commented Aug 7, 2013 at 6:35
  • 1
    try to delete the last line then check the content of Evaluation backup Commented Aug 7, 2013 at 6:37

1 Answer 1

6

The documentation for execSql says:

Execute a single SQL statement …

Call db.execSql once for each statement.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah it's worked, thanks master @CL. :D and I feel sorry for the documentation :(

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.