首頁 美術繪圖 | 美術設計 | 熱門標籤 | 首選 | 首頁宣傳 | 近期作品 論壇: 發表 | 美術工作 | 美術比賽 | 展覽活動 | 美術相關 | 一般討論 | 美術同好 CG 討論 :: Photoshop | Painter | 3D 行動 | AMP

【 立即註冊 】 : 更改個人資料 : : 登入

會員名稱: 登入密碼: 保持登入

Fix Recover Corrupted Sqlite3 Database Files with Errors

發表新主題 回覆主題 討論區 Windows, Linux, Perl, PHP, C/C++, Driver, Web 理論、應用、硬體、軟體

| 1頁, 共1
人氣點閱:2104 發表人
Fix Recover Corrupted Sqlite3 Database Files with Errors 2012-09-19 12:39
/ / /

Fix/Recover Corrupted Sqlite3 Database Files



1. Do PRAGMA integrity_check or quick_check



C:\>sqlite3.exe corrupted_files.db
SQLite version 3.7.14 2012-09-03 15:42:36
Enter ".help" for instructions
Enter SQL statements terminated with a ";"


sqlite> pragma quick_check;
*** in database main ***
On page 2 at right child: invalid page number 256
Page 233 is never used
sqlite>


If you see "OK", then the database files would be good in theory.


2. Found SQLite Error, Dump whatever we could dump


代碼:

sqlite> .dump


or

代碼:

C:\>echo .dump | sqlite3.exe corrupted_files.db > corrupted_files.TXT



3. Review and Edit the TXT SQL files



(3.1) Edit & Review the SQL TXT to see if how many data you save back;
(3.2) At EOF, remove "ROOLBACK;", add "COMMIT;"
(3.3) Save the TXT file

代碼:

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE `tttt` (`snoo` INTEGER PRIMARY KEY  NOT NULL  DEFAULT '', `ipad` INTEGER DEFAULT '', `urii` VARCHAR DEFAULT '', `date` DATETIME DEFAULT CURRENT_DATE);
INSERT INTO "tttt" VALUES(0,0,'https://vovo2000.com/paintbbs/','2010-08-22');
...
... (...SNIP...)
...
INSERT INTO "tttt" VALUES(58863,0,'https://www.google.com.tw/','2012-08-07');
/**** ERROR: (11) database disk image is malformed *****/
/**** ERROR: (11) database disk image is malformed *****/
/*** REMOVE THIS LINE!!! ANALYZE sqlite_master; ***/
/*** REMOVE THIS LINE!!! ROLLBACK; -- due to errors ***/

/*** ADD COMMIT at last line ***/
COMMIT;


4. Backup and Load SQL TXT into Sqlite



(4.1) copy/cp corrupted_files.db __corrputed__backup.db
(4.2) delete/rm corrupted_files.db
(4.3) Load revised SQL TXT to re-init

代碼:

C:\>sqlite3 -init corrupted_files.TXT corrupted_files.db
-- Loading resources from corrupted_files.db

SQLite version 3.7.14 2012-09-03 15:42:36
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select count(*) from tttt;
40095
sqlite> PRAGMA quick_check;
ok
sqlite>

________________

美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
Type



繪圖畫廊設計藝廊
攝影相簿留言板
最愛收藏分類標籤
暱稱: Type
註冊: 2002-11-30
發表: 11173
來自: vovo2000.com
V幣: 901761





資訊相關理論、技術、管理、應用、產品等
發表新主題 回覆主題