2014年9月16日 星期二

What's SQLite Virtual Table (SQL) 甚麼是 SQLITE 的 虛擬資料表

  因為要做這方面的報告,雖然這還是有點奇怪,但是就想想好的例子來說懂關於virtual Table ,原本是要來說Virtual Shapefile Virtual Dbf use sqlite extend spatialite ,英文很爛有錯誤麻煩糾正我一下,但其實是找不太到的,因為其實概念就是virtual table 這樣,所已找了sqlite 的手冊,以下加上我的翻譯::

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.

虛擬表格是連結外部檔案(不存在此資料庫內),例如load dbf or load shapefile(這裡有點是關於Geometry了),不過大同小異拉,我們今天要載入dbf檔案進入我們sqlite3的database內,但是不在sqlite3資料庫內占取空間,就是用load virtual table 了


In general, you can do anything with a virtual table that can be done with an ordinary table ,except that you cannot create indices or triggers on a virtual table, some virtual table implementations  might impose additional restrictions. For example . many virtual tables are read-only

  一般來說,你可以做些平常在對一般table下的select等 命令來對virtual table來作,
除了建立index 和新增更改欄位這類的命令,基本上大部分的virtual table都是唯獨(read- only)

The <module-name> is the name of an object that implements the virtual table. The <module-name> must be registered with the SQLite database connection using sqlite3_create_module() or sqlite3_create_module_v2() prior to issuing the CREATE VIRTUAL TABLE statement. The module takes zero or more comma-separated arguments. The arguments can be just about any text as long as it has balanced parentheses. The argument syntax is sufficiently general that the arguments can be made to appear as column definitions in a traditional CREATE TABLE statement. SQLite passes the module arguments directly to the xCreate and xConnect methods of the module implementation without any interpretation. It is the responsibility of the module implementation to parse and interpret its own arguments.

這一塊我真的看不太懂,不過大致上看了一下內容,因該不重要 =_=

A virtual table is destroyed using the ordinary DROP TABLE statement. There is no DROP VIRTUAL TABLE statement.

刪除virtual table 和一般刪除table 是一樣的 指令如下:
drop table virtual_table_name ;


Summary ::
1.載入外部檔案,大部份該檔案其實本身也是個資料表
2.其實也可以完全load進sqlite變成一個真實的資料表,但是virtual的話就不占空間
3.缺點是幾乎都是唯讀的!!


以下是簡報內容可公開不分::

Outlines
What’s Virtual Table ?

SQL Operation (Geometry Operation)




以上簡報公開可公開部份









沒有留言:

張貼留言