日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

小型數(shù)據(jù)庫的選擇(輕量級數(shù)據(jù)庫)(轉)

 ylzrx 2012-03-07

型數(shù)據(jù)庫的選擇(輕量級數(shù)據(jù)庫)
    一直使用Sql Server開發(fā),沒有用過Access之外其它的DB。最近正想做個小型工具,這種小東西當然不可能用Sql Server數(shù)據(jù)庫啦,可又不想用Access,于是想起在Blog中看到關于小型數(shù)據(jù)庫的文章,收集如下資料:
    據(jù)稱,在國外,需要使用客戶端數(shù)據(jù)庫的情況中,有30%左右的開發(fā)者選擇Access,有30%的開發(fā)者選擇MSDE 2000,有30%的開發(fā)者選擇Embedded Firebird,剩余10%選擇其他小型數(shù)據(jù)庫,如SQLite,MySQL 等。


引用
Embedded Firebird DB 簡介
最近在學習 Firebird Embeded Database。作為一款單文件型小型數(shù)據(jù)庫,F(xiàn)irebird 具有很多吸引人的特征,比如支持事務、支持存儲過程、觸發(fā)器等,而且 Embeded 版本的 Firebird 在 .NET 開發(fā)中只需要拷貝兩個文件:一個 fbembed.dll (非托管但不需要注冊的動態(tài)鏈接庫)和一個 ADO.NET Data Provider 的 FirebirdSql.Data.Firebird.dll。這些特征都非常適合那些需要在客戶端存儲一些數(shù)據(jù),但又不想安裝數(shù)據(jù)庫(比如MSDE)軟件的情形。

據(jù)稱,在國外,需要使用客戶端數(shù)據(jù)庫的情況中,有30%左右的開發(fā)者選擇Access,有30%的開發(fā)者選擇MSDE 2000,有30%的開發(fā)者選擇Embedded Firebird,剩余10%選擇其他小型數(shù)據(jù)庫,如SQLite,MySQL 等。

上面所說的Access,MSDE 2000,Embedded Firebird,SQLite等都是可以免費再分發(fā)(free redistributable)的數(shù)據(jù)庫。相比而言,MSDE 2000 顯著缺點是需要安裝,最大優(yōu)點是和服務器端的 SQL Server 編程模型一致,開發(fā)便利。Access的顯著缺點是功能較少,不支持事務等常用功能,最大優(yōu)點是簡單、多數(shù)開發(fā)者都很熟悉,部署也很方便。SQLite支持事務,也是一款單文件數(shù)據(jù)庫,比較不足的是 .NET Data Provider 還不是很成熟。Firebird則同時具有:單文件、部署簡單不需安裝(只需 XCOPY 兩個文件)、支持事務、存儲過程、觸發(fā)器,.NET Data Provider比較穩(wěn)定成熟等優(yōu)點。

Firebird 本身有SuperServer和Embedded版本之分,后者只能本機訪問,不接受TCP連接。對于開發(fā)者而言,從Embedded數(shù)據(jù)庫切換到SuperServer,只需更改數(shù)據(jù)庫連接串中的ServerType值就行。

但是,在你正式決定使用?Firebird 之前,請你注意下面這個 known issue(已知問題): Firebird 數(shù)據(jù)庫文件不能放置在含有中文等字符的路徑中。Firebird 的文件名不可以用中文字符,所在路徑的任何部分如果含有中文字符,都將無法訪問到數(shù)據(jù)庫。舉個例子,中文Windows桌面所在的目錄一般是“C:Documents and Settings用戶名桌面”,如果數(shù)據(jù)庫文件放置在桌面上,就無法訪問到。當然,F(xiàn)irebird 內部是可以存儲中文字符的,因為它支持 GB2312 和 UNICODE 等字符集。

我已向 Firebird 開發(fā)者報告了這個 BUG,希望能早日解決這個 BUG。

需要注意一點,連接串中的 Database 地址如果使用相對路徑,請一定注意這個相對路徑是相對于 fbembed.dll 所在目錄的。
-------------------------

Sqlite中文資料

介紹
這是嵌入式SQL數(shù)據(jù)庫引擎SQLite(SQLite Embeddable SQL Database Engine)的一個擴展。SQLite是一個實現(xiàn)嵌入式SQL數(shù)據(jù)庫引擎的 C語言庫(C library)。用SQLite連接的程序可以使用SQL數(shù)據(jù)庫,但不需要運行一個單獨的關系型數(shù)據(jù)庫管理系統(tǒng)進程(separate RDBMS process)。
SQLite不是一個用于連接到大型數(shù)據(jù)庫服務器(big database server)的客戶端庫(client library)。SQLite是一個服務器。SQLite直接讀寫(reads and writes directly)在硬盤上的數(shù)據(jù)庫文件。
注:更多關于SQLite的資料請查看SQLite的網(wǎng)站(http:///)。
安裝
請閱讀在安裝包里的 INSTALL 文件。或者使用PEAR installer with "pear install sqlite"。SQLite已經內置了,你不需要安裝任何附加的軟件(additional software)。
Windows users可以下載SQLite擴展DLL(php_sqlite.dl)。
需求
為了可以使用那些函數(shù),你必須編譯帶上SQLite支持PHP(compile PHP with SQLite support),或者在你的php.ini加載SQLite擴展。
資源類型
有兩個在SQLite界面(the SQLite Interface)可用的資源。第一個是數(shù)據(jù)庫連接(the database connection),第二是計算結果設置(the result set)。
預定義常量
函數(shù)sqlite_fetch_array()和sqlite_current()使用一個常量表示不同的返回類型。下面的常量(表格 1.)已經被定義:
表格 1. SQLite 常量
常量名 意義
SQLITE_ASSOC Columns are returned into the array having the fieldname as the array index.
SQLITE_BOTH Columns are returned into the array having both a numerical index and the fieldname as the array index.
SQLITE_NUM Columns are returned into the array having a numerical index to the fields. This index starts with 0, the first field in the result. 
運行時配置
這些函數(shù)的行為受到全局配置文件 php.ini 的影響。
表格 2. SQLite Configuration Options
Name Default Changeable
sqlite.assoc_case 0 PHP_INI_ALL 
For further details and definition of the PHP_INI_* constants see ini_set(). 
以下是該配置選項的簡要解釋。
sqlite.assoc_case int
Whether to use mixed case (0), upper case (1) or lower case (2) hash indexes.
This option is primarily useful when you need compatibility with other database systems, where the names of the columns are always returned as uppercase or lowercase, regardless of the case of the actual field names in the database schema.
The SQLite library returns the column names in their natural case (that matches the case you used in your schema). When sqlite.assoc_case is set to 0 the natural case will be preserved. When it is set to 1 or 2, PHP will apply case folding on the hash keys to upper- or lower-case the keys, respectively.
Use of this option incurs a slight performance penalty, but is MUCH faster than performing the case folding yourself using PHP script. 
目錄
sqlite_array_query —— 發(fā)送一條 SQL 查詢,并返回一個數(shù)組。
sqlite_busy_timeout —— 設置超時時間(busy timeout duration),或者頻繁的用戶失去權限(disable busy handlers)。
sqlite_changes —— 返回被最新的SQL 查詢(changed by the most recent SQL statement)改變的行數(shù)。
sqlite_close —— 關閉一個打開的SQLite數(shù)據(jù)庫。
sqlite_column —— 在當前的行中取得一列(a column from the current row of a result set)。
sqlite_create_aggregate —— Register an aggregating UDF for use in SQL statements。
sqlite_create_function —— Registers a "regular" User Defined Function for use in SQL statements。
sqlite_current —— 在返回的數(shù)組中取得當前的行(the current row from a result set as an array)。
sqlite_error_string —— 返回錯誤代碼的原始描述(the textual description of an error code)。
sqlite_escape_string —— 釋放一個用于查詢的字符串(Escapes a string for use as a query parameter)。
sqlite_fetch_array —— 取得下一行并設置成一個數(shù)組(the next row from a result set as an array)。
sqlite_fetch_single —— 取得第一列并設置成一個字符串(Fetches the first column of a result set as a string)。
sqlite_fetch_string —— sqlite_fetch_single()的別名。
sqlite_field_name —— 取得結果中指定字段的字段名。
sqlite_has_more —— 返回是否有更多可用的行(whether or not more rows are available)。
sqlite_last_error —— 返回數(shù)據(jù)庫的最新的錯誤代碼(the error code of the last error for a database)。
sqlite_last_insert_rowid —— 返回最新插入的行的行號(the most recently inserted row)。
sqlite_libencoding —— 返回SQLite庫(SQLite library)的編碼(encoding)。
sqlite_libversion —— 返回SQLite庫(SQLite library)的版本。
sqlite_next —— 返回下一行的行號。
sqlite_num_fields —— 取得結果集中字段的數(shù)目。
sqlite_num_rows —— 取得結果集中行的數(shù)目。
sqlite_open —— 打開一個SQLite數(shù)據(jù)庫。如果文件不存在則嘗試創(chuàng)建之。
sqlite_popen —— 用永久連接的方式打開一個SQLite數(shù)據(jù)庫。如果文件不存在則嘗試創(chuàng)建之。
sqlite_query —— 發(fā)送一條 SQL 查詢,并返回一個結果句柄(a result handle)。
sqlite_rewind —— 倒回第一行(Seek to the first row number)。
sqlite_seek —— 在緩存結果中查找特定的行號(Seek to a particular row number of a buffered result set)。
sqlite_udf_decode_binary —— Decode binary data passed as parameters to an UDF。
sqlite_udf_encode_binary —— Encode binary data before returning it from an UDF。
sqlite_unbuffered_query —— 發(fā)送一條 SQL 查詢,并不獲取和緩存結果的行。

關于Sqlite的問答
為什么選擇 SQLite 來捆綁而不用其它數(shù)據(jù)庫?恐怕 PHP 想把 ASP 趕下臺了。
對于 PHP 所開發(fā)的留言本,整站等程序,為什么使用率比 ASP 低呢?很大原因是數(shù)據(jù)庫的安裝,對于一般用戶,安裝一個 MySQL 數(shù)據(jù)庫相對比較難的,而 Access 則只需要修改數(shù)據(jù)庫路徑即可,數(shù)據(jù)庫和站點文件放在一起,非常方便?,F(xiàn)在好了,PHP5 將 SQLite 捆綁了,相信以后會出很多相關的應用程序,而這些應用程序的數(shù)據(jù)庫安裝相信可以和 ASP 媲美,速度又比 MySQL 快上 1-2 倍(官方的數(shù)據(jù)),存儲量又不是問題(最大可超過 2TB-2000GB,官方數(shù)據(jù))。只是對于并發(fā)訪問我比較擔心,還沒有測試過不知道如何。呵呵,但是相信這是 PHP 的明智選擇,即使服務器不支持 SQLite ,也可以通過加載 php_sqlite.dll 來實現(xiàn) SQLite 的支持。恩,為什么沒有早點想到使用它呢?恐怕是有以下幾點原因:
1.當初還不健壯--即使現(xiàn)在也不知道是不是健壯,代碼就那么幾百K,呵呵,和 MySQL 對比起來……
2.感覺好像有點文件系統(tǒng)的味道,就一個數(shù)據(jù)庫文件包含了所有數(shù)據(jù)……
3.不支持表的無損修改,也就是說不支持 ALTER TABLE ,這恐怕帶來了不少麻煩。改變數(shù)據(jù)表結構就要重建表,不過有其他方法解決。
4.只支持 left join ,不過差不多夠用了,對小型程序來說。
5.優(yōu)化數(shù)據(jù)表恐怕比較麻煩。
優(yōu)點還是很多的,我看了下:
1.安裝方便
2.支持大量數(shù)據(jù)
3.支持大部分SQL
4.弱數(shù)據(jù)類型
5.速度快(沒有測試,官方說法)
6.體積小
7.具備 Command 窗口,下載一個 SQLite.exe 文件即可對數(shù)據(jù)庫進行命令行操作,和 MySQL 差不多的樣子,不過顯然不如 MySQL 友好和強大。
8.完全公開的源代碼和版權

其他想到再說,感覺 SQLite 很不錯的,PEAR 已經提供擴展類支持了。有興趣下載了看看。
翻譯了一部分 FAQ, 英語水平差,可能不準確,翻譯得很累,有興趣的幫忙翻譯幾段。
常見問答(FAQ)
(最后更新:2004/03/20 15:34:56)
http://www./faq.html
(1) 如何創(chuàng)建自增字段?
(2) SQLite 支持哪些數(shù)據(jù)類型?
(3) 為什么能向 SQLite 數(shù)據(jù)庫的整型字段中插入字符串?
(4) 為什么 SQLite 認為表達式 '0'=='00' 為真?
(5) 為什么 SQLite 不允許在同一張表里使用 '0' 和 '0.0' 作為兩個不同的行的主鍵?
(6) 為什么不能在 Linux box 中讀取在 SparcStation 中創(chuàng)建的 SQLite 數(shù)據(jù)庫?
(7) 多個應用程序或者同一個應用程序的多個例程能同時存取同一個數(shù)據(jù)庫文件嗎?
(8) Is SQLite threadsafe?
(9) 如何列出一個 SQLite 數(shù)據(jù)庫中的所有的表/索引?
(10) 有對 SQLite 數(shù)據(jù)庫的任何已知的大小的限制嗎?
(11) 在 SQLite 中 VARCHAR 的最大長度是多少?
(12) SQLite 是否支持 BLOB 類型?
(13) 如何從一個已存在的 SQLite 數(shù)據(jù)表中添加/刪除字段?
(14) 我刪除了很多數(shù)據(jù)但是數(shù)據(jù)庫文件并沒有減小,是不是 Bug?
(15) 是否能將 SQLite 用于商業(yè)用途而不用交版稅? 
--------------------------------------------------------------------------------
(1) 如何創(chuàng)建自增字段?
簡單的回答:一個聲明為 INTEGER PRIMARY KEY 的字段將自動增加。
這里是詳細的答案: 從 SQLite 的 2.3.4 版本開始,如果你將一個表中的一個字段聲明為 INTEGER PRIMARY KEY,那么無論你何時向該表的該字段插入一個 NULL 值,這個 NULL 值將自動被更換為比表中該字段所有行的最大值大 1 的整數(shù);如果表為空,那么將被更換為 1。比如,假設你有這樣的一張數(shù)據(jù)表: 
CREATE TABLE t1(
a INTEGER PRIMARY KEY,
b INTEGER
);
在這張數(shù)據(jù)表里,聲明
INSERT INTO t1 valueS(NULL,123);
在邏輯意義上等價于:
INSERT INTO t1 valueS((SELECT max(a) FROM t1)+1,123);
至于 SQLite 的 2.2.0 到 2.3.3 版本,如果你向一個 INTEGER PRIMARY KEY 字段插入 NULL 值, 它將被替換為一個唯一的整數(shù),但它是個半隨機的整數(shù)。通過這種方式產生的唯一鍵將不是連續(xù)的。而 SQLite 的 2.3.4 及其以后版本,唯一鍵將是連續(xù)的直到其最大值超過 2147483647。這是 32 位整型的最大值因而不能繼續(xù)增加。因此在 SQLite 的 2.3.3 及其早期版本,并發(fā)的插入嘗試將返回一個半隨機的鍵生成算法。
從 2.2.3 版本開始,一個新的名為 sqlite_last_insert_rowid() 的 API 函數(shù)將為最近的插入操作返回一個整型鍵。詳細資料請查看 API 手冊

--------------------------------------------------------------------------------
(2) SQLite 支持哪些數(shù)據(jù)類型?
SQLite 是弱類型的。所有數(shù)據(jù)以無終止的字符串存儲。在 CREATE TABLE 中,字段名后面的數(shù)據(jù)類型信息將被忽略(大部分),你可以往任何字段插入你想要的數(shù)據(jù)類型,而不用管那個字段被聲明為什么類型。
這個規(guī)則的一個例外是字段為 INTEGER PRIMARY KEY 類型。這樣的字段強制一個整型。往 INTEGER PRIMARY KEY 字段插入任何非整型數(shù)據(jù)將產生一個錯誤。
這是一個在 SQLite 的數(shù)據(jù)類型 中更深入解釋這一概念的頁面。

--------------------------------------------------------------------------------
(3) 為什么能向 SQLite 數(shù)據(jù)庫的整型字段中插入字符串?
這是一個特點,不是錯誤。SQLite 是弱類型的。任何數(shù)據(jù)都能夠插入任何字段中。你可以往整型字段中插入任意長度的字符串,或者往布爾字段中插入浮點數(shù),或者往字符字段中插入日期。在 CREATE TABLE 命令中你指定給這個字段的數(shù)據(jù)類型不會限制插入這個字段的數(shù)據(jù)。所有的字段可以插入任意長度的字符串。(有一個例外:以 INTEGER PRIMARY KEY 為類型的字段只允許整數(shù)。如果你嘗試往一個 INTEGER PRIMARY KEY 字段插入非整型數(shù)據(jù),將產生一個錯誤。)
然而數(shù)據(jù)類型是影響值的比較的。因為在一個數(shù)字類型(比如 "integer")字段中,任何字符串在進行比較和排序時是被看成處理成數(shù)值的數(shù)字。考慮這兩個命令序列:
CREATE TABLE t1(a INTEGER UNIQUE); CREATE TABLE t2(b TEXT UNIQUE);
INSERT INTO t1 valueS('0'); INSERT INTO t2 valueS(0);
INSERT INTO t1 valueS('0.0'); INSERT INTO t2 valueS(0.0);
在左邊的序列中,第二條插入語句將失敗。這種情況下,當字符串 '0' 和 '0.0' 插入一個數(shù)字類型字段中時將被處理成數(shù)字而 0==0.0 違反了唯一性約束。但是右邊序列中的第二條插入語句正常執(zhí)行。這種情況下,常量 0 和 0.0 被處理成字符串意味著它們是截然不同的。
這是一個在 SQLite 的數(shù)據(jù)類型 中更深入解釋這一概念的頁面。

--------------------------------------------------------------------------------
(4) 為什么 SQLite 認為表達式 '0'=='00' 為真?
在 2.7.0 之后,表達式不成立。
但是如果兩個值之一在一個數(shù)字類型字段中比較,另一個將被轉化為數(shù)字而不是字符串,而且結果成立。例如:
CREATE TABLE t3(a INTEGER, b TEXT);
INSERT INTO t3 valueS(0,0);
SELECT count(*) FROM t3 WHERE a=='00';
上面序列中的 SELECT 語句返回 1。字段 "a" 是數(shù)字類型所以在 WHERE 子句中字符串 '00' 被轉換成一個數(shù)字作為和 'a' 的比較。0==00 所以這個測試返回 TRUE?,F(xiàn)在考慮一個不同的 SELECT 語句:
SELECT count(*) FROM t3 WHERE b=='00';
在這種情況下答案是 0。'b' 是一個 text 字段,文本不匹配 '00'。'0'!='00' 因此 WHERE 子句返回 FALSE 而返回行數(shù)為 0。
這是一個在 SQLite 的數(shù)據(jù)類型 中更深入解釋這一概念的頁面。

--------------------------------------------------------------------------------
(5) 為什么 SQLite 不允許在同一張表里使用 '0' 和 '0.0' 作為兩個不同的行的主鍵?
你的主鍵必定是數(shù)字類型。將數(shù)據(jù)類型改成 TEXT 后即可正常運行。
每一行必須有一個唯一的主鍵。作為一個數(shù)字類型的字段,SQLite 認為 '0' 和 '0.0' 的值是相同的,因為他們在數(shù)字上的比較是相等的(看前面的問題)因此值不是唯一的。

--------------------------------------------------------------------------------
(6) 為什么不能在 Linux box 中讀取在 SparcStation 中創(chuàng)建的 SQLite 數(shù)據(jù)庫?
你需要升級你的 SQLite 庫到 2.6.3 或更新版本。
你的 linux box 上的 x86 處理器是 little-endian (意味著整數(shù)中的最低位的字節(jié)排在前面),但是 Sparc 是 big-endian (最高位的字節(jié)排在前面)。在 SQLite 低于 2.6.3 版本的時候,創(chuàng)建于 little-endian 體系中的 SQLite 數(shù)據(jù)庫不能運行于 big-endian 的機器上。從 2.6.3 版本開始,SQLite 應該能夠讀寫數(shù)據(jù)庫文件而不管創(chuàng)建數(shù)據(jù)庫的機器的字節(jié)順序如何。

--------------------------------------------------------------------------------
(7) 多個應用程序或者同一個應用程序的多個例程能同時存取同一個數(shù)據(jù)庫文件嗎?
多個程序能夠在同一時間打開同一個數(shù)據(jù)庫,能夠同時執(zhí)行 SELECT 命令。但是一次只能有一個進程改變數(shù)據(jù)庫。
Win95/98/ME 操作系統(tǒng)缺乏讀/寫鎖定支持。在 2.7.0 版本之前,這意味著在 Windows 下你一次只能對數(shù)據(jù)庫做單一的讀處理。這個問題在 2.7.0 版本中已經通過一個 Windows 下的用戶空間讀寫概率統(tǒng)計策略(implementing a user-space probabilistic reader/writer locking strategy)Windows 現(xiàn)在和 UNIX 一樣允許多重的讀操作。
The locking mechanism used to control simultaneous access might not work correctly if the database file is kept on an NFS filesystem. This is because file locking is broken on some NFS implementations. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time. On Windows, Microsoft's documentation says that locking may not work under FAT filesystems if you are not running the Share.exe daemon. People who have a lot of experience with Windows tell me that file locking of network files is very buggy and is not dependable. If what they say is true, sharing an SQLite ourse-grained. SQLite locks the entire database. Big database servers (PostgreSQL, Oracle, etc.) generally have finer grained locking, such as locking on a single table or a single row within a table. If you have a massively parallel database application, you should consider using a big database server instead of SQLite.
database between two or more Windows machines might cause unexpected problems.
Locking in SQLite is very c 
When SQLite tries to access a file that is locked by another process, the default behavior is to return SQLITE_BUSY. You can adjust this behavior from C code using the sqlite_busy_handler() or sqlite_busy_timeout() API functions. See the API documentation for details.
If two or more processes have the same database open and one process creates a new table or index, the other processes might not be able to see the new table right away. You might have to get the other processes to close and reopen their connection to the database before they will be able to see the new table.

--------------------------------------------------------------------------------
(8) Is SQLite threadsafe?
Yes. Sometimes. In order to be thread-safe, SQLite must be compiled with the THREADSAFE preprocessor macro set to 1. In the default distribution, the windows binaries are compiled to be threadsafe but the linux binaries are not. If you want to change this, you'll have to recompile.
"Threadsafe" in the previous paragraph means that two or more threads can run SQLite at the same time on different "sqlite" structures returned from separate calls to sqlite_open(). It is never safe to use the same sqlite structure pointer simultaneously in two or more threads.
Note that if two or more threads have the same database open and one thread creates a new table or index, the other threads might not be able to see the new table right away. You might have to get the other threads to close and reopen their connection to the database before they will be able to see the new table.
Under UNIX, you should not carry an open SQLite database across a fork() system call into the child process. Problems will result if you do.

--------------------------------------------------------------------------------
(9) 如何列出一個 SQLite 數(shù)據(jù)庫中的所有的表/索引?
If you are running the sqlite command-line access program you can type ".tables" to get a list of all tables. Or you can type ".schema" to see the complete database schema including all tables and indices. Either of these commands can be followed by a LIKE pattern that will restrict the tables that are displayed.
From within a C/C++ program (or a script using Tcl/Ruby/Perl/Python bindings) you can get access to table and index names by doing a SELECT on a special table named "SQLITE_MASTER". Every SQLite database has an SQLITE_MASTER table that defines the schema for the database. The SQLITE_MASTER table looks like this:
CREATE TABLE sqlite_master (
type TEXT,
name TEXT,
tbl_name TEXT,
rootpage INTEGER,
sql TEXT
);
For tables, the type field will always be 'table' and the name field will be the name of the table. So to get a list of all tables in the database, use the following SELECT command:
SELECT name FROM sqlite_master
WHERE type='table'
ORDER BY name;
For indices, type is equal to 'index', name is the name of the index and tbl_name is the name of the table to which the index belongs. For both tables and indices, the sql field is the text of the original CREATE TABLE or CREATE INDEX statement that created the table or index. For automatically created indices (used to implement the PRIMARY KEY or UNIQUE constraints) the sql field is NULL.
The SQLITE_MASTER table is read-only. You cannot change this table using UPDATE, INSERT, or DELETE. The table is automatically updated by CREATE TABLE, CREATE INDEX, DROP TABLE, and DROP INDEX commands.
Temporary tables do not appear in the SQLITE_MASTER table. Temporary tables and their indices and triggers occur in another special table named SQLITE_TEMP_MASTER. SQLITE_TEMP_MASTER works just like SQLITE_MASTER except that it is only visible to the application that created the temporary tables. To get a list of all tables, both permanent and temporary, one can use a command similar to the following: 
SELECT name FROM
(SELECT * FROM sqlite_master UNION ALL
SELECT * FROM sqlite_temp_master)
WHERE type='table'
ORDER BY name
--------------------------------------------------------------------------------
(10) 有對 SQLite 數(shù)據(jù)庫的任何已知的大小的限制嗎?
As of version 2.7.4, SQLite can handle databases up to 2^41 bytes (2 terabytes) in size on both Windows and Unix. Older version of SQLite were limited to databases of 2^31 bytes (2 gigabytes).
SQLite arbitrarily limits the amount of data in one row to 1 megabyte. There is a single #define in the source code that can be changed to raise this limit as high as 16 megabytes if desired.
There is a theoretical limit of about 2^32 (4 billion) rows in a single table, but this limit has never been tested.
There is also a theoretical limit of about 2^32 tables and indices.
The name and "CREATE TABLE" statement for a table must fit entirely within a 1-megabyte row of the SQLITE_MASTER table. Other than this, there are no constraints on the length of the name of a table, or on the number of columns, etc. Indices are similarly unconstrained.
The names of tables, indices, view, triggers, and columns can be as long as desired. However, the names of SQL functions (as created by the sqlite_create_function() API) may not exceed 255 characters in length.

--------------------------------------------------------------------------------
(11) 在 SQLite 中 VARCHAR 的最大長度是多少?
Remember, SQLite is typeless. A VARCHAR column can hold as much data as any other column. The total amount of data in a single row of the database is limited to 1 megabyte. You can increase this limit to 16 megabytes, if you need to, by adjusting a single #define in the source tree and recompiling.
For maximum speed and space efficiency, you should try to keep the amount of data in a single row below about 230 bytes.

--------------------------------------------------------------------------------
(12) SQLite 是否支持 BLOB 類型?
You can declare a table column to be of type "BLOB" but it will still only store null-terminated strings. This is because the only way to insert information into an SQLite database is using an INSERT SQL statement, and you can not include binary data in the middle of the ASCII text string of an INSERT statement.
SQLite is 8-bit clean with regard to the data it stores as long as the data does not contain any '\000' characters. If you want to store binary data, consider encoding your data in such a way that it contains no NUL characters and inserting it that way. You might use URL-style encoding: encode NUL as "%00" and "%" as "%25". Or, you might consider encoding your binary data using base-64. There is a source file named "src/encode.c" in the SQLite distribution that contains implementations of functions named "sqlite_encode_binary() and sqlite_decode_binary() that can be used for converting binary data to ASCII and back again, if you like.

--------------------------------------------------------------------------------
(13) 如何從一個已存在的 SQLite 數(shù)據(jù)表中添加/刪除字段?
SQLite does not support the "ALTER TABLE" SQL command. If you what to change the structure of a table, you have to recreate the table. You can save existing data to a temporary table, drop the old table, create the new table, then copy the data back in from the temporary table.
For example, suppose you have a table named "t1" with columns names "a", "b", and "c" and that you want to delete column "c" from this table. The following steps illustrate how this could be done: 
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,B);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,B);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;
--------------------------------------------------------------------------------
(14) 我刪除了很多數(shù)據(jù)但是數(shù)據(jù)庫文件并沒有減小,是不是 Bug?
不是的。當你從 SQLite 刪除數(shù)據(jù)之后,未使用的磁盤空間被添加到一個內在的“空閑列表”中用于存儲你下次插入的數(shù)據(jù)。磁盤空間并沒有丟失,但是也不向操作系統(tǒng)返回磁盤空間。
如果你刪除了大量的數(shù)據(jù)且想要減小數(shù)據(jù)庫文件,執(zhí)行 VACUUM 命令(2.8.1 或更新版本)。VACUUM 命令將重建數(shù)據(jù)庫will reconstruct the database from scratch. This will leave the database with an empty free-list and a file that is minimal in size. Note, however, that the VACUUM can take some time to run (around a half second per megabyte on the Linux box where SQLite is developed) and it can use up to twice as much temporary disk space as the original file while it is running. 

--------------------------------------------------------------------------------
(15) 是否能將 SQLite 用于商業(yè)用途而不用交版稅?
可以。SQLite 是公開的。代碼的任何部分都沒有聲明所有權。你可以用它來做你想要的任何事情

本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/partner4java/archive/2010/03/25/5416693.aspx

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多