How to compress (or cleanup) Sqlite database after delete?

Is there a way to compress (or cleanup) a Sqlite database after a large number of rows have been deleted?
For example, if I have a database file around 1Mb and delete all the rows the database file remains at 1Mb (despite being empty). If I then open this file in Sqlite Administrator and click on "CleanUp" the size goes down to 4kb.
Is this functionality available from inside my app?
Thanks

I'm finally getting some time to look at this but not doing too well.
Running the following code gives the below error message:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myDB.sql"];
int success;
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
// My first delete statement
// My second delete statement
// My third delete statement
// VACUUM STATEMENT
const char *sql4 = "VACUUM";
sqlite3_stmt *statement4;
if (sqlite3preparev2(database, sql4, -1, &statement4, NULL) != SQLITE_OK) {
NSAssert1(0, @"Error: failed to prepare vacuum with message '%s'.", sqlite3_errmsg(database));
success = sqlite3_step(statement4);
sqlite3_reset(statement4);
if (success != SQLITE_DONE) {
NSAssert1(0, @"Error: failed to execute vacuum with message '%s'.", sqlite3_errmsg(database));
sqlite3_finalize(statement4);
sqlite3_close(database);
error:
Error: failed to execute vacuum with message 'unable to open database file'.
I know the database file is open ok because the rows are being deleted fine. The problem is just cleaning up the database file with the VACUUM command.
Has anyone successfully run this statement on the iPhone?

Similar Messages

  • How to retrieve data from the Database after deleting rows from VO ?

    Hello,
    I am using Jdeveloper 11.1.2.1.0
    I have a master and a child .
    So according my use case when a value in the master vo changes the corresponding child has to be deleted.
    but when i change back to any other value i want to undo the delete operation and get back the values in the child.
    Is there any way to do it?
    Regards,
    Nigel.
    Edited by: Nigel Thomas on Mar 29, 2012 5:07 AM
    Edited by: Nigel Thomas on Mar 29, 2012 5:09 AM

    Hi all,
    I want to do a validation based on a SelectOneChoice List Value.
    Based on which value in the select one choice is being selected, thedata from the VO should be DELETED or NOT-DELETED.
    To do this I wrote a Managed Bean and the delete part is working fine if a particular value of the SelectOneChoice is selected.
    Since the rows are deleted from the VO, after I change the SelectOneChoice value to the previous one I cannot retrieve the rows.
    I thought of two ways:
    1. As the Deleting option in the SelectOneChoice is selected the rows should be deleted from the VO and when reverted back to not-Deleting option the Rollback of Transaction method written in the Managed Bean should take place.
    2. As the Deleting option is selected the data should be deleted from the VO and when reverted back to non-Deleting option, a query should be made from the Database.
    The first plan was dropped because it is not VO-specific. If there are more than 1 VO in the page then whatever changes are made in the page will be reverted back as soon ad Rollback of transaction is done.
    So the now i am left to go with the second plan.
    Is there any way to implement the second plan?
    If so...Will it compromise the performance of the application?
    Or else, Is there any other way to implement my Use-Case ???
    Regards,
    Nigel.

  • How to reduce the size of file after delete some datas?

    The size of the database file isn't smaller than ago after delete some data from database.
    How to reduce the size of file after delete some datas?

    Hi,
    What BDB release are you using? If it's one of the latest releases, then what you are looking for is the DB->compact() method:
    http://download.oracle.com/docs/cd/E17076_01/html/api_reference/C/dbcompact.html
    The DB->compact() method compacts Btree, Hash, and Recno access method databases, and optionally returns unused Btree, Hash or Recno database pages to the underlying filesystem. Please let me know if it helps.
    Bogdan Coman

  • How can you get a calendar back after deleting it

    How can you get a calendar back after deleting it

    You will have to restore the device from a backup on icloud.  (this assumes you have backups turned on in settings>icloud)
    http://support.apple.com/kb/HT1766?viewlocale=en_US&locale=en_US
    Go to Settings>General>Reset and tap Erase All Content and Settings.  This will erase your device.  Then you will go through the setup screens again as you did when your device was new, and when given the option, select Restore from iCloud Backup.

  • HT1766 How can i restore all my data after deleting the apps? can i syncing back from the macbook?

    How can i restore back all my data after deleting the apps and re-install back.
    After reinstall back stll retrieve all my data.
    Can i syncing back the original frm my macbook since last update is Mar

    Favor the route via iTunes and local storage on the computer. MUCH faster than any cloudy backup, no matter the speed of your Internet connection. No network beats the speed of a hard drive. Just make sure there's enough room on the computer before you start, must contain all that's on the iGadget.

  • How to save report file to database after generation

    I am generating a report using oracle reports 6i. The report is a .pdf file. I need to save this file in a database table to that i can show a link on the application to view the file online. How can i achieve this functionality?
    Thanks.

    Yes you can. Find about BLOB fields.

  • How to re-build the Production database after failover

    We have performed a failover in our environment by the below method . It was worst we are not able to bring up the production the only choice left over is failover.
    We have enabled the flash back and created a checkpoint then failover.
    SQL> select max(sequence#) from v$log_history;
    MAX(SEQUENCE#)
    9221
    SQL> alter system set db_recovery_file_dest_size=14G;
    System altered.
    SQL> alter system set db_recovery_file_dest='/u01/oradata/flashback';
    System altered.
    SQL> alter database recover managed standby database cancel;
    Database altered.
    SQL> alter database flashback on;
    Database altered.
    SQL> create restore point before_open_standby guarantee flashback database;
    Restore point created.
    SQL> alter database activate standby database;
    Database altered.
    SQL> select database_role from v$database;
    DATABASE_ROLE
    PRIMARY
    SQL> shutdown immediate;
    ORA-01109: database not open
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup
    ORACLE instance started.
    SQL> select max(sequence#) from v$log_history;
    MAX(SEQUENCE#)
    9221 (This is the log sequence same after the failover also)
    after the we have nearly some 30 log sequence are generated but it started from the no 1.
    Now we need to rebuild the Production DB and to sync with the standby.. please help us with the steps and suggest some documents.

    Hi,
    Please take a look at this http://shivanandarao.wordpress.com/2012/08/28/dataguard-failover/
    SHANOJ     
    Handle:     SHANOJ
    Status Level:     Newbie (5)
    Registered:     Feb 15, 2006
    Total Posts:     154
    Total Questions:     *25 (21 unresolved)*
    Name     SHANOJ
    Location     Chennai - India
    Occupation     DBA
    Biography     OCP 10G, LPI, ITIL V3
    If you feel your questions have been answered, then please consider closing your threads as answered by providing appropriate points rather than leaving it open. Follow the forums etiquette.

  • How to compress and extract files & databases from current BC site?

    Hello All -
    It's been a good run with BC, but we're under new management and are starting over with a different CMS.    I would like to extract all data from the current site (text from all pages, images, pdfs, etc from media library, information from customers).  I know how to export customer reports, but is there a way to compress and extract everything in a comprehensive way?
    Thanks so much - any help would be much appreciated! 
    Also... need to do this ASAP...

    Hi,
    Unfortunately it's not a comprehensive as you may be hoping.  You'll need to export everything using the existing tools mentioned in the article below.  It's similar concept of migration one site to another.  
    - http://kb.worldsecuresystems.com/203/bc_2038.html
    I'm afraid there's no automated feature for this at the moment.
    Kind regards,
    -Sidney

  • How to insert text into sqlite database from AutoCompleteTextField

    Dear Friends,
                       I want to know that whether it is possible to store values into the database from AutoCompleteText field?????????if it is posssible please explain that how we can do that............Please Reply.......I am waiting for the reply......
    With Love,
    Nithin

    You can use SSIS package for that
    Start a new Integration Services project in Business  Intelligence Development Studio/ SSDT. Add a new SSIS package with a data flow task. Add a OLEDB source to connect to Oracle server and add a OLEDB Destination to connect to your local database.
    Select tables for source and destination. On executing package source data will get transferred to your local database.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How can I get refund codes back after deleting the e-mail?

    A mistake by iTunes had me purchase Taylor Swift's Red album for full price even though I had previously purchased a few singles. iTunes sent me an e-mail with some refund codes, but I can no longer locate the e-mail. I looked on my account under "Gifts" but they are not there. How can I retrieve these codes?
    Thank you!!

    You'll have to contact the iTunes Store again and ask if they can resend.
    Regards.

  • Unable to update database after delete table content

    in my project i import .dmp file ..& create userto access database tables...but whn i deleet record from tab....it is deleted...but in actual proect database it not reflect remains as it is ....so wht shold i do
    plz giv solution

    992371 wrote:
    in my project i import .dmp file ..& create userto access database tables...but whn i deleet record from tab....it is deleted...but in actual proect database it not reflect remains as it is ....so wht shold i do
    plz giv solution[url https://forums.oracle.com/forums/message.jspa?messageID=10894779#10894779]duplicate post
    Edited by: EdStevens on Mar 8, 2013 7:09 AM

  • How long alias name keep as used after delete?

    I need to create new account with my old alias name, i deleted this alias from my account long time ago, but i can't create new account with this name ("This email address is already taken")... how long?

    but i can't create new account with this name
    Once the account has expired it can no longer be used.
    "Changing the active or inactive status of an alias"
    From  here >  MobileMe: Email aliases can no longer be added, changed, or deleted

  • How to purge PERFSTAT.STATS$SQLTEXT table, after deleting snapshots

    I had an alarm on the free space of the PERFSTAT tablespace. In order to free up some space I tried to delete some old StatsPack snapshots, with the following query:
    DELETE from perfstat.stats$snapshot where snap_time < sysdate - 10 ;
    COMMIT;
    After running it the space usage on the tablespace was not significantly reduced. I checked again and I saw that the table PERFSTAT.STATS$SQLTEXT was very big, almost 8 Gb, but all the other tables were a lot smaller. I read somewhere that the sppurge.sql procedure, that comes with Oracle, could be used to purge the statspack data, but that it comes with the lines related to PERFSTAT.STATS$SQLTEXT commented, because it is a big query and it can take a lot of undo space. I tried to run the followiung query, which I found in the forum, by Don Burleson, but it failed, because of running out of undo:
    DELETE /*+ index_ffs(st)*/
    FROM perfstat.stats$sqltext st
    WHERE (hash_value, text_subset) NOT IN (
    SELECT /*+ hash_aj full(ss) no_expand*/ hash_value, text_subset
    FROM perfstat.stats$sql_summary ss
    WHERE snap_id NOT IN (SELECT DISTINCT snap_id FROM perfstat.stats$snapshot)
    COMMIT;
    Is there any way to know if the PERFSTAT.STATS$SQLTEXT table has records that could be purged, and an easier way, that don't use as much undo, to purge it?
    My oracle version is:
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE 9.2.0.7.0 Production
    TNS for Solaris: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    I. Neva
    Oracle DBA

    Is there any way to know if the PERFSTAT.STATS$SQLTEXT table has records that could be purged, yes, just transform Delete to Select
    SELECT /*+ index_ffs(st)*/ count(*)
    FROM perfstat.stats$sqltext st
    WHERE (hash_value, text_subset) NOT IN (
    SELECT /*+ hash_aj full(ss) no_expand*/ hash_value, text_subset
    FROM perfstat.stats$sql_summary ss
    WHERE snap_id NOT IN (SELECT DISTINCT snap_id FROM perfstat.stats$snapshot)
    and an easier way, that don't use as much undo, to purge it?yes. do it smaller chunks
    BEGIN
    LOOP
    DELETE /*+ index_ffs(st)*/
    FROM perfstat.stats$sqltext st
    WHERE (hash_value, text_subset) NOT IN (
    SELECT /*+ hash_aj full(ss) no_expand*/ hash_value, text_subset
    FROM perfstat.stats$sql_summary ss
    WHERE snap_id NOT IN (SELECT DISTINCT snap_id FROM perfstat.stats$snapshot)
    ) AND ROWNUM<=10000;
    EXIT WHEN SQL%ROWCOUNT = 0;
    COMMIT;
    END LOOP;
    COMMIT;
    END;
    /

  • How to stop photos from reappearing again after deleting on ipad?

    i'm out of space on my ipad.  apple's updates keep demanding MY space (another story...) so i keep deleting MY paid apps & now my personal photos to make room for their "latest" which will do little for me compared to losing my apps & 1000s of photos.  enough griping...
    i synced my ipad through itunes & "unchecked" the box about photos.  voila!  all my photos & "albums" were gone - giving me some much needed space.  temporarily.  now while all the "albums" (events, camera roll, photo stream, etc) are gone, ALL the photos are still there on the photo "page".  they were gone for a while but they repopulated so now i have no real gain in my capacity area.
    can any of you help me get rid of ALL the photos forever?  they were taken with my iphone, my nikon & dvds of OLD (1930s) pics.  they're on my macbook & iphone - that's enough!
    i've just spent over 3 hours trying everything imaginable & at 2:05am, it's time to throw in the towel.  WHY can't these beautiful, elegant machines that apple creates TRULY be intuitive?  there's no reason to have all these questions from obviously intelligent people as to what should be a straightforward process with these devices that we now all depend on. 
    thank you.  thank you. thank you.

    forgot to add - i'm on version 7.0.6 as i don't have enough room for the most recent upgrades, hence my trying to create some space...

  • How to download keynote with new Account after deleting previous one?

    Hi,
    I have changed my Apple ID and deleted my keynote which i have dwonloaded with my previous Apple account. But when I tried to download keynote using my recent Account to the same Mac it only shows "update" option with previous account. Is there any way i could download it with my recent Account?
    thanks

    Thanks, I know its a silly issue to forward here.
    I tried several times but what happened was I had a pending update I tried with my previous account. So when i updated and remove it. I was able to download from my recent account.

Maybe you are looking for

  • HPLaserJetService.exe has encountered a problem and needs to close.

    I continue to recieve an error message that states the following: HPLaserJetService.exe has encountered a problem and needs to close.  Right before the message appears my pc slows down and sometimes programs that i am in shut down. I have not issues

  • How do i forward an e-mail to someone?

    I have some job leads to forward to my relative and I cannot figure out how to forward. This should be a simple task however I am having a problem figuring this out

  • Apple Wireless Bluetooth Keyboard no longer works after OSX update

    After installing the latest OSX update yesterday (something about iChat encryption), Apple Bluetooth Keyboard no longer works with my iMac. When I restarted the iMac after installation was completed, the iMac would no longer recognise my Bluetooth Ap

  • Create an XML file from Java

    I'm a new user of XML. I've a very important question: Is it possible create an XML file using some java package? If yes what package i must use? JDOM is the right product? Thanks

  • BPM Message Split in Block par for Each: Just last message is sent n-times

    Hello everybody, we got BPM with a message split. In a par-for-each block the message is send. Asuming I have 3 lines in the multiline container element, I can see in SXMB_MONI that that message is send 3 times. The error is, that 3 times the last me