下載 sqlite-3.3.6.tar.gz
解壓並拷貝至你想要安裝到的目錄下,我選擇的是/usr/local/sqlite-3.3.6
接著在終端裡:
# cd /usr/local/sqlite-3.3.6
# ./configure
# make
# make install
# make doc
make 的時候提示錯誤
../sqlite-3.3.6/src/tclsqlite.c: In function `DbUpdateHandler':
../sqlite-3.3.6/src/tclsqlite.c:333: warning: passing arg 3 of `Tcl_ListObjAppendElement' makes pointer from integer without a cast
……
這個都是tcl 相關的錯誤, 可以先安裝ActiveTcl 以解決. 假如你不需要tcl 支援, 那麼這個錯誤可以這樣避免:
# ./configure --disable-tcl --prefix=/usr/local/sqlite-3.3.6
# make 如果提示沒有可以編譯的檔案,則是第一次make 時已經執行過了,接著下面做就可以了;如果此次是第一次編譯,應該不會再提示出錯了
# make install
# make doc
測試是否安裝成功
# cd /usr/lcoal/sqlite-3.3.6
# ./sqlite3 text.db // 這也是進入資料庫的方法
如果安裝成功,會出現下面這樣的資訊
SQLite version 3.3.6
Enter ".help" for instructions
sqlite>
接下來就可以自由操作啦,和在windows 下是一樣的啦。
二、 SQLite 基本操作
如以下操作:建立表、插入、查詢:
sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values('hello!',10);
sqlite> insert into tbl1 values('goodbye', 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite>
注意每句SQL 陳述式後一定要有分號 semicolon 。
Special commands to sqlite3 :
sqlite> .help
.databases List names and files of attached databases
.exit Exit this program
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.tables List the tables