SQLite在Linux下的安装

2014-11-24 17:48:27 · 作者: · 浏览: 1

下载 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