SQLite 中 create table 与 create virtual table 有什么区别?
Whats difference between create table vs create virtual table in SQLite?
create Virtual table 语句是否仅在 RAM 上创建 table?如果那是真的,你怎么能用更少的 ram 设备处理大数据?
演示语句的机制-在sqllite中创建虚拟table。
如果你想举个例子,下面是一个简单的声明:
//Create a FTS3 Virtual Table
private static final String DATABASE_CREATE =
"CREATE VIRTUAL TABLE " + FTS_VIRTUAL_TABLE + " USING fts3(" +
KEY_CUSTOMER + "," +
KEY_NAME + "," +
KEY_ADDRESS1 + "," +
KEY_ADDRESS2 + "," +
KEY_CITY + "," +
KEY_STATE + "," +
KEY_ZIP + "," +
KEY_SEARCH + "," +
" UNIQUE (" + KEY_CUSTOMER + "));";
我觉得documentation说的很清楚了:
A virtual table is an interface to an external storage or computation
engine that appears to be a table but does not actually store
information in the database file.
虚拟表可以驻留在 RAM 中。更常见的是它们是某种磁盘文件或存储在另一个数据库中。
你可以在这个link中看到很好的解释:
https://sqlite.org/vtab.html
From the perspective of an SQL statement, the virtual table object looks like any other table or view. But behind the scenes, queries and updates on a virtual table invoke callback methods of the virtual table object instead of reading and writing on the database file.
A virtual table might represent an in-memory data structures. Or it might represent a view of data on disk that is not in the SQLite format. Or the application might compute the content of the virtual table on demand.
虚拟 table 未使用通常的机制实现;相反,对它的所有操作都被重定向到某个虚拟 table 模块。
这实际意味着什么取决于虚拟 table 模块如何选择实现它们。
有虚拟 table 模块可以访问存储在数据库外部的数据。
但是在FTS的情况下,创建虚拟的table也会在同一个数据库中创建几个shadow tables,存储实际的table数据和全文索引的内容。这意味着您不必管理任何外部数据,并且所有操作都自动受到常规事务管理的保护。
create Virtual table 语句是否仅在 RAM 上创建 table?如果那是真的,你怎么能用更少的 ram 设备处理大数据?
演示语句的机制-在sqllite中创建虚拟table。
如果你想举个例子,下面是一个简单的声明:
//Create a FTS3 Virtual Table
private static final String DATABASE_CREATE =
"CREATE VIRTUAL TABLE " + FTS_VIRTUAL_TABLE + " USING fts3(" +
KEY_CUSTOMER + "," +
KEY_NAME + "," +
KEY_ADDRESS1 + "," +
KEY_ADDRESS2 + "," +
KEY_CITY + "," +
KEY_STATE + "," +
KEY_ZIP + "," +
KEY_SEARCH + "," +
" UNIQUE (" + KEY_CUSTOMER + "));";
我觉得documentation说的很清楚了:
A virtual table is an interface to an external storage or computation engine that appears to be a table but does not actually store information in the database file.
虚拟表可以驻留在 RAM 中。更常见的是它们是某种磁盘文件或存储在另一个数据库中。
你可以在这个link中看到很好的解释: https://sqlite.org/vtab.html
From the perspective of an SQL statement, the virtual table object looks like any other table or view. But behind the scenes, queries and updates on a virtual table invoke callback methods of the virtual table object instead of reading and writing on the database file.
A virtual table might represent an in-memory data structures. Or it might represent a view of data on disk that is not in the SQLite format. Or the application might compute the content of the virtual table on demand.
虚拟 table 未使用通常的机制实现;相反,对它的所有操作都被重定向到某个虚拟 table 模块。
这实际意味着什么取决于虚拟 table 模块如何选择实现它们。
有虚拟 table 模块可以访问存储在数据库外部的数据。 但是在FTS的情况下,创建虚拟的table也会在同一个数据库中创建几个shadow tables,存储实际的table数据和全文索引的内容。这意味着您不必管理任何外部数据,并且所有操作都自动受到常规事务管理的保护。