Simon, Forgot to ask 1 thing. What is a quick way to copy an entire table from database1 to database2?
Thanks, Andrew -----Original Message----- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Andrew Stewart Sent: Wednesday, November 16, 2016 7:16 AM To: 'SQLite mailing list' <sqlite-users@mailinglists.sqlite.org> Subject: Re: [sqlite] Issue with Malformed table Simon, Thank you for the response. I will give it a try. I can do this with 2 different database connections and then just transfer all of the tables from database1 to database2. Close database1. Remove/rename the file for database1. Close database2. Rename file for database2 to file for database1. Open connection to database1. Andrew -----Original Message----- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Simon Slavin Sent: Wednesday, November 16, 2016 7:07 AM To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Subject: Re: [sqlite] Issue with Malformed table 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 Notice: This electronic transmission contains confidential information, intended only for the person(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or any other use of this email is strictly prohibited. If you have received this transmission by error, please notify us immediately by return email and destroy the original transmission immediately and all copies thereof. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users