SQLite

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>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值