Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3616268
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:28:42+00:00 2026-05-18T22:28:42+00:00

I want to completely clean all the contents in a SQLite3 table in my

  • 0

I want to completely clean all the contents in a SQLite3 table in my iPhone app. My MySQL experience told me that I should use TRUNCATE. But it seems that SQLite3 doesn’t support TRUNCATE (at least I got an error when preparing statement when I use the sentence TRUNCATE my_table_Name).

So I turn to DELETE FROM. Two questions: 1) Will DELETE FROM clean my table in a thorough way? 2) I tried the following code and it worked. But I highly doubted that there are unnecessary or even wrong codes in it. Can anyone help me take a look at it?

Thanks in advance.

Di

-(void)deleteAllUser {
    NSString *ns_sql = [NSString stringWithFormat:@"DELETE FROM %@", [Config USER_TABLE_NAME]];
    const char *sql = [ns_sql cStringUsingEncoding:NSUTF8StringEncoding];
    sqlite3_stmt *statement = nil;

    sqlite3* db = ...; //get the database instance

    if(sqlite3_prepare_v2(db, sql, -1, &statement, nil) != SQLITE_OK) {
        return;
    }

    //Without this line, table is not modified
    int code = sqlite3_step(statement);

    if (code == SQLITE_ROW) {
        //Do nothing here...
    }

    sqlite3_finalize(statement);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:28:43+00:00Added an answer on May 18, 2026 at 10:28 pm

    I think

    if (code == SQLITE_ROW) {
    //Do nothing here…
    }

    this code should be like

    if (code == SQLITE_DONE) {
    //Do nothing here…
    }

    If you want to get any message then you can return YES from here and NO from else(if you change return type to BOOL from void).This can help you in showing messaeges.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to note that this is COMPLETELY a made up question. I am
I am completely new to Jena/TDB. All I want to do is to load
Basically I want to setup a replication server for mysql datbase. I am completely
I making an application with my own keyboard and I want to completely DISABLE
With reXml using Ruby, I have a particular element and I want to completely
I'm completely new to MATLAB and I want to know what my options are
i'm completely noob with jboss administration. i want to have a few applications (wars)
I'm completely new in web service. I want to study about it and the
What are some reasons why I wouldn't want to disable IIS logging completely for
I'm trying to create a espeak based talking clock completely in python I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.