Search code examples
iphoneiosfmdb

How to remove all data from table using FMDB


I want to delete all data from table in my database. I am using FMDB.And i have used this code but it will not delete data from my table.

-(BOOL) deleteAll
{

    FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
    [db open];

    BOOL success =  [db executeUpdate:@"TRUNCATE TABLE customers"];

    [db close];

    return success;
    return YES;
}

Solution

  • Try to use this code.

    BOOL success =  [db executeUpdate:@"DELETE FROM customers"];
    

    As long as i know Sqlite does not support TRUNCATE query.