Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQLite sqlite_schema missing

SQLite sqlite_schema missing

Scheduled Pinned Locked Moved Database
databasesqlitequestioncsharphelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    How can I get the number of the tables from a sqlite3 database ? I downloaded from here: SQLite Sample Database And Its Diagram (in PDF format)[^] chinook.db But when I try to get all tables from this database:

    SELECT * FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'

    I got:

    no such table: sqlite_schema

    I also tried to create a database on my own:

    SQLite::Database db("C:\\Temp\\mydb.bd3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
    db.exec(_T("CREATE TABLE sqlite_schema(type TEXT, name TEXT, tbl_name TEXT, rootpage INTEGER, sql TEXT)"));
    db.exec(_T("PRAGMA foreign_keys = ON"));

    and

    db.exec(_T("DROP TABLE IF EXISTS master"));
    db.exec(_T("CREATE TABLE master(masterid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT)"));
    db.exec(_T("DROP TABLE IF EXISTS app"));
    db.exec(_T("CREATE TABLE app (appid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT)"));
    db.exec(_T("DROP TABLE IF EXISTS device"));
    db.exec(_T("CREATE TABLE device (deviceid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, masterid INTEGER, appid INTEGER, name TEXT, FOREIGN KEY(masterid) REFERENCES master(masterid), FOREIGN KEY(appid) REFERENCES app(appid))"));

    but when I try the same SQL:

    SELECT * FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'

    I got the same error:

    no such table: sqlite_schema

    How can I assure to retrieve all tables from a db3 (db) file ?

    R 1 Reply Last reply
    0
    • _ _Flaviu

      How can I get the number of the tables from a sqlite3 database ? I downloaded from here: SQLite Sample Database And Its Diagram (in PDF format)[^] chinook.db But when I try to get all tables from this database:

      SELECT * FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'

      I got:

      no such table: sqlite_schema

      I also tried to create a database on my own:

      SQLite::Database db("C:\\Temp\\mydb.bd3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
      db.exec(_T("CREATE TABLE sqlite_schema(type TEXT, name TEXT, tbl_name TEXT, rootpage INTEGER, sql TEXT)"));
      db.exec(_T("PRAGMA foreign_keys = ON"));

      and

      db.exec(_T("DROP TABLE IF EXISTS master"));
      db.exec(_T("CREATE TABLE master(masterid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT)"));
      db.exec(_T("DROP TABLE IF EXISTS app"));
      db.exec(_T("CREATE TABLE app (appid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT)"));
      db.exec(_T("DROP TABLE IF EXISTS device"));
      db.exec(_T("CREATE TABLE device (deviceid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, masterid INTEGER, appid INTEGER, name TEXT, FOREIGN KEY(masterid) REFERENCES master(masterid), FOREIGN KEY(appid) REFERENCES app(appid))"));

      but when I try the same SQL:

      SELECT * FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'

      I got the same error:

      no such table: sqlite_schema

      How can I assure to retrieve all tables from a db3 (db) file ?

      R Offline
      R Offline
      Richard Deeming
      wrote on last edited by
      #2

      SQLite Forum: Documentation issue (wrong table name) in FAQ, point 7[^]

      The name has been changed to "sqlite_schema" as of version 3.33.0. The older name "sqlite_master" is still accepted as an alias for backwards compatibility. The FAQ is for version 3.33.0. You must be using an older version of SQLite.

      Assuming you're not using 3.33.0 or later, try using the sqlite_master table instead.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      _ 2 Replies Last reply
      0
      • R Richard Deeming

        SQLite Forum: Documentation issue (wrong table name) in FAQ, point 7[^]

        The name has been changed to "sqlite_schema" as of version 3.33.0. The older name "sqlite_master" is still accepted as an alias for backwards compatibility. The FAQ is for version 3.33.0. You must be using an older version of SQLite.

        Assuming you're not using 3.33.0 or later, try using the sqlite_master table instead.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        Thanks a lot. That was the issue. I have a small request: can you share which structure has this table, sqlite_master ? I need a database_id, table_id, or appropriate.

        1 Reply Last reply
        0
        • R Richard Deeming

          SQLite Forum: Documentation issue (wrong table name) in FAQ, point 7[^]

          The name has been changed to "sqlite_schema" as of version 3.33.0. The older name "sqlite_master" is still accepted as an alias for backwards compatibility. The FAQ is for version 3.33.0. You must be using an older version of SQLite.

          Assuming you're not using 3.33.0 or later, try using the sqlite_master table instead.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #4

          Ahh, I think I have found it: SQLite: sqlite_master (internal schema object)[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups