On 16 Nov 2016, at 2:52pm, Andrew Stewart <astew...@arguscontrols.com> wrote:
> I have a table that is giving me errors. I can recover the > data from another source, but need a way to clear the table. This process is very fast and easy, but it may not help with your form of corruption. Open the database in the SQLite Shell Tool (can be downloaded from the SQLite download page). Use the command .dump <tablename> This sometimes allows you to extract data from corrupt tables. And sometimes does not. > Read row from table1 - detect error (SQL logic error or missing database). > Have been able to read other rows from same table successfully. > Create temporaryTable - for transferring good data from bad table to. Never do this. If one table in a SQLite database is showing corruption, regard the entire file as corrupt and do not attempt to make any changes to it at all, even deleting stuff from it. Any changes you make to it may result in making more of your original data un-rescuable. You do this because you may, for example, have one page of the corrupt database file marked both as in use by a table and as available for use with new data. So writing any new data to it could lose even more data from an existing table. So how do you rescue data from one database file and write it to another ? You open two different SQLite connections to two different SQLite database files. If your library doesn't allow that you can instead allow one SQLite connection to access two databases using the ATTACH command: <https://www.sqlite.org/lang_attach.html> So my recommendation, if you do want your own program to use the SQLite API to extract data from a corrupt database, is that you open two different connections to two different databases. If you can't do that, then make the connection to a new database in which you're going to store the rescued data, but then ATTACH to it the corrupt database which you will only read from, never write to. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users