Discussion:
[sqlite] Version of the database
Cecil Westerhof
2016-05-05 16:15:22 UTC
Permalink
I know how to get the version of the running version of SQLite, but is
there a way to get the version with which the database was created?
--
Cecil Westerhof
Simon Slavin
2016-05-05 16:19:59 UTC
Permalink
Post by Cecil Westerhof
I know how to get the version of the running version of SQLite, but is
there a way to get the version with which the database was created?
Unfortunately I do not think this information is stored anywhere.

One often finds three version numbers stored:

A) The version of the engine which was used to create the file.
B) The earliest version of the engine which has made changes to the file.
C) The latest version of the engine which has made changes to the file.

I don't think SQLite stores any of these.

Simon.
Cecil Westerhof
2016-05-05 16:26:25 UTC
Permalink
Post by Simon Slavin
Post by Cecil Westerhof
I know how to get the version of the running version of SQLite, but is
there a way to get the version with which the database was created?
Unfortunately I do not think this information is stored anywhere.
A) The version of the engine which was used to create the file.
B) The earliest version of the engine which has made changes to the file.
C) The latest version of the engine which has made changes to the file.
I don't think SQLite stores any of these.
​Aah, OK. So the info I get with .dbinfo is about the program, not the file?



​At the moment I do not need the information. But I always like to be
prepared. ;-)
--
Cecil Westerhof
Richard Hipp
2016-05-05 16:38:39 UTC
Permalink
Post by Simon Slavin
Post by Cecil Westerhof
I know how to get the version of the running version of SQLite, but is
there a way to get the version with which the database was created?
A) The version of the engine which was used to create the file.
B) The earliest version of the engine which has made changes to the file.
C) The latest version of the engine which has made changes to the file.
I don't think SQLite stores any of these.
SQLite stores the version number of the last writer in the database
header. There is no PRAGMA to retrieve this, but you can see it by
running the ".dbinfo" command in the shell.
--
D. Richard Hipp
***@sqlite.org
Simon Slavin
2016-05-05 17:24:18 UTC
Permalink
Post by Richard Hipp
There is no PRAGMA to retrieve this, but you can see it by
running the ".dbinfo" command in the shell.
I was wrong. Believe Richard, not me.

Simon.
Cecil Westerhof
2016-05-05 16:22:19 UTC
Permalink
Post by Cecil Westerhof
I know how to get the version of the running version of SQLite, but is
there a way to get the version with which the database was created?
​With the command line program I can get it with:
.dbinfo
one of the things it gives is:
software version: 3008010
so it is 3.8.10,but would it also be possible to get in my Java program?
--
Cecil Westerhof
Simon Slavin
2016-05-05 16:27:25 UTC
Permalink
Post by Cecil Westerhof
.dbinfo
software version: 3008010
I don't know if this is from something stored in the file. My guess is that it's more likely to be the version of SQLite in the shell tool you're using, using one of these:

SQLITE_EXTERN const char sqlite3_version[] :

<https://www.sqlite.org/c3ref/libversion.html>

the "sqlite_version()" function:

<https://www.sqlite.org/lang_corefunc.html>

Simon.
R Smith
2016-05-05 22:42:36 UTC
Permalink
The file header contains the SQLite version that most recently modified
the schema. You can see this using the cli, but not a pragma.

If you are willing to dig a bit, you can retrieve it by reading the
first 100 bytes or so from the file and examining the 4 bytes at offset
96. It's a big-endian 32-bit integer containing the version, and also
another 32-bit integer (4-byte) value just prior at offset 92 is a
counter of how many changes were made since using that library version.
Together these can be quite useful information.

The Integer value of the version would be a number like this: 3012034 -
starting with a 3 always for SQLite3 and then the next 3 digits the
minor version (12 in the example) and the last 3 the release (34 in the
example).

For more information on values stored in the header - see here:
https://www.sqlite.org/fileformat2.html#database_header

Cheers,
Ryan
Post by Cecil Westerhof
Post by Cecil Westerhof
I know how to get the version of the running version of SQLite, but is
there a way to get the version with which the database was created?
.dbinfo
software version: 3008010
so it is 3.8.10,but would it also be possible to get in my Java program?
John G
2016-05-26 16:31:09 UTC
Permalink
I don't see the '.dbinfo' command in the shell in the version supplied
with MacOS X 10.10 (Yosemite) - 3.8.8.3.
Was this introduced after this.
I know Apple is a bit slow in updating, but I can't use a personally
compiled verion.
John G
Post by R Smith
The file header contains the SQLite version that most recently modified
the schema. You can see this using the cli, but not a pragma.
If you are willing to dig a bit, you can retrieve it by reading the first
100 bytes or so from the file and examining the 4 bytes at offset 96. It's
a big-endian 32-bit integer containing the version, and also another 32-bit
integer (4-byte) value just prior at offset 92 is a counter of how many
changes were made since using that library version. Together these can be
quite useful information.
The Integer value of the version would be a number like this: 3012034 -
starting with a 3 always for SQLite3 and then the next 3 digits the minor
version (12 in the example) and the last 3 the release (34 in the example).
https://www.sqlite.org/fileformat2.html#database_header
Cheers,
Ryan
Post by Cecil Westerhof
I know how to get the version of the running version of SQLite, but is
Post by Cecil Westerhof
there a way to get the version with which the database was created?
.dbinfo
software version: 3008010
so it is 3.8.10,but would it also be possible to get in my Java program?
_______________________________________________
sqlite-users mailing list
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Simon Slavin
2016-05-26 16:35:47 UTC
Permalink
Post by John G
Was this introduced after this.
Yes, it's a very recent new thing.
Post by John G
I know Apple is a bit slow in updating, but I can't use a personally
compiled verion.
Download the precompiled version from the "Precompiled Binaries" section on the download page.

Simon.
Richard Hipp
2016-05-26 17:11:48 UTC
Permalink
Post by John G
I don't see the '.dbinfo' command in the shell in the version supplied
with MacOS X 10.10 (Yosemite) - 3.8.8.3.
Was this introduced after this.
Added in 3.8.9 (2015-04-08)
--
D. Richard Hipp
***@sqlite.org
Continue reading on narkive:
Loading...