database 如何查找 SQLITE 数据库文件版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9646353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find SQLITE database file version
提问by Srikanth S
I have few sqlite database files. I want to know the database file version i.e 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).
我有几个 sqlite 数据库文件。我想知道数据库文件版本,即数据库是用 sqlite2 或 sqlite3 或任何其他主/子版本(不是 sqlite 库或驱动程序或 user_version 或 schema_version)创建的。
回答by saurabh
You can write this command in any sqlite explorer which will give the sqlite version
您可以在任何提供 sqlite 版本的 sqlite 资源管理器中编写此命令
select sqlite_version();
回答by kev
You can get version number of a database file by the Magic Header String:
您可以通过以下方式获取数据库文件的版本号Magic Header String:
- sqlite2 ==> first 48 bytes
- sqlite3 ==> first 16 bytes
- sqlite2 ==> 前 48 个字节
- sqlite3 ==> 前 16 个字节
$ 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 filecommand:
更简单的方法是使用file命令:
$ file file2.db
file2.db: SQLite 2.x database
$ file file3.db
file3.db: SQLite 3.x database
回答by galian
Get user_version: run sql: PRAGMA user_version;
获取 user_version: 运行 sql: PRAGMA user_version;
Get schema_version: PRAGMA schema_version;
获取 schema_version: PRAGMA schema_version;
When create database file (.db), user_version can be set by user.
创建数据库文件(.db)时,user_version 可以由用户设置。
回答by MSD561
The correct answer from version 3 of sqlite program is:
sqlite 程序第 3 版的正确答案是:
sqlite3 --version
回答by Pablo Santa Cruz
You can extract the information from the header file. It will require you to open the database file 'by hand' but I don't know if there is an API function to get this information.
您可以从头文件中提取信息。它将要求您“手动”打开数据库文件,但我不知道是否有 API 函数来获取此信息。
回答by Techgeeks1
You have to open the python shell then write these steps:
你必须打开python shell,然后编写这些步骤:
import sqlite3
sqlite3.sqlite_version
回答by 341152 Chyi
Check manual file
检查手册文件
sqlite3.version The version number of this module, as a string. This is not the version of the SQLite library.
sqlite3.version 此模块的版本号,作为字符串。这不是 SQLite 库的版本。
sqlite3.version_info The version number of this module, as a tuple of integers. This is not the version of the SQLite library.
sqlite3.version_info 此模块的版本号,作为整数元组。这不是 SQLite 库的版本。
sqlite3.sqlite_version The version number of the run-time SQLite library, as a string.
sqlite3.sqlite_version 运行时 SQLite 库的版本号,作为字符串。
sqlite3.sqlite_version_info The version number of the run-time SQLite library, as a tuple of integers.
sqlite3.sqlite_version_info 运行时 SQLite 库的版本号,作为整数元组。
回答by Mark
I found this to be the easiest method to determine the version of sqlite. Run the Python IDLE Shell, then do the following:
我发现这是确定 sqlite 版本的最简单方法。运行 Python IDLE Shell,然后执行以下操作:
>>> import sqlite3
>>> sqlite3.version
'2.6.0'
In my case it was 2.6.0. Hope this helps... Mark
就我而言,它是 2.6.0。希望这有助于...马克
回答by George Williams
If you have a data connection to it in Visual Studio, you can right click on the data base in Server Explorer, select properties, and the version will be shown in the properties window, (under Version, surprisingly). You might need to left click the database first to open it.
如果你在 Visual Studio 中有数据连接,你可以在服务器资源管理器中右键单击数据库,选择属性,版本将显示在属性窗口中,(在版本下,令人惊讶)。您可能需要先左键单击数据库才能打开它。

