BitSensei

programmer knowledge

  • Increase font size
  • Default font size
  • Decrease font size
Home APIs sqlite
sqlite

Listing the tables in a sqlite3 database

E-mail Print PDF

The following code lists the table names in a sqlite3 database.

 
    sqlite3_stmt *stmt;
 
    if (!sqlite3_prepare_v2(db, 
        "select name from sqlite_master where type='table' order by name", 
        -1, &stmt, NULL))
    {
        while (sqlite3_step(stmt) == SQLITE_ROW)
        {
            const char *name = (const char *)sqlite3_column_text(stmt, 0);
 
            /* do stuff */
        }
 
        sqlite3_finalize(stmt);
    }
 
Last Updated on Monday, 18 May 2009 19:18