1. sqlite: http://www.sqlite.org/index.html
下载sqlite-3_6_23.zip, 一个执行程序:sqlite3.exe
使用方法:sqlite3 ex1 ----创建ex1.db库
创建表:
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>
sqlite> CREATE TABLE tbl2 (
...> f1 varchar(30) primary key,
...> f2 text,
...> f3 real
...> );
sqlite>
查询表的情况
$ sqlite3 ex1
sqlite> select * from sqlite_master;
改变输出格式
.mode ( "csv", "column", "html", "insert","line", "list", "tabs", and "tcl".)
sqlite> .mode insert new_table
sqlite> select * from tbl1;
INSERT INTO 'new_table' VALUES('hello',10);
INSERT INTO 'new_table' VALUES('goodbye',20);
sqlite>
输出到文件
sqlite> .mode list
sqlite> .separator |
sqlite> .output test_file_1.txt
sqlite> select * from tbl1;
sqlite> .exit
$ cat test_file_1.txt
hello|10
goodbye|20
$
查询库中的数据表
sqlite> .tables
tbl1
tbl2
sqlite>
显示创建库和索引的语句CREATE TABLE and CREATE INDEX
sqlite> .schema
create table tbl1(one varchar(10), two smallint)
CREATE TABLE tbl2 (
f1 varchar(30) primary key,
f2 text,
f3 real
)
sqlite> .schema tbl2
CREATE TABLE tbl2 (
f1 varchar(30) primary key,
f2 text,
f3 real
)
数据库
sqlite> .databases
支持In-Memory Databases
using the special filename ":memory:".
sqlite>