Alex Rivera | Logout

How to find database file version?

Asked 2012-03-10T12:18:44.723
125

I have a few SQLite database files. I want to know the database file version (if the database was created with sqlite2 or sqlite3 or any other main/sub version) not the SQLite library or driver or user_version or schema_version.

Edit
Report

1 Answer

109

You can get version number of a database file by the Magic Header String:

  • sqlite2 ==> first 48 bytes
  • sqlite3 ==> first 16 bytes

$ head -c 48 file2.db
** This file contains an SQLite 2.1 database **

$ head -c 16 file3.db
SQLite format 3

The easier way is using the file command:

$ file file2.db
file2.db: SQLite 2.x database

$ file file3.db
file3.db: SQLite 3.x database
answered 2012-03-10T12:26:46.210

Your Answer