SQLite Database Integrity Detection

Source: Internet
Author: User
Tags sqlite sqlite database

/************************************************************************************************** Function Name: integritycheck* function Description: Database integrity detection * Input parameters: None * Output parameters: None * return value: 0: Full/1: Damage * Other Instructions: * Revision date version number modified content *-------------------- ---------------------------* *********************************************************************************** /#defineDB_OK0/* Full */#defineDB_ERROR1/* Damage */sqlite3 *obj_db;char g_objfile[255] = "DB.DB3"; int Integritycheck (void) {/* Open database */sqlite3_open (G_objfile, &obj_db); BOOL integrityverified = db_error;sqlite3_stmt *integrity = null;//integrity_check check includes: Disorderly sequence of records, missing pages, incorrect records, lost indexes, uniqueness constraints, Non-null constraint//if (SQLITE3_PREPARE_V2 (obj_db, "PRAGMA integrity_check;",-1, &integrity, NULL) = = SQLITE_OK)//quick_check No Check constraints, take shorter if (Sqlite3_prepare_v2 (obj_db, "PRAGMA quick_check;",-1, &integrity, NULL) = = Sqlite_ok) {while (SQL Ite3_step (Integrity) = = Sqlite_row) {Const unsigned char *result = sqlite3_column_text (integrity, 0); if (Result && strcmp ((const char *) result, (const char *) "OK") = = 0) {integrityverified = Db_ok;break;}} Sqlite3_finalize (integrity);} /* Close Database */sqlite3_close (obj_db); return integrityverified;}

  

SQLite Database Integrity Detection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.