SQLite学习笔记

Windows获取SQLite

 1.主页: www.sqlite.org

 2.下载 Precompiled Binaries For Windows

 3.设置系统环境PATH

使用

 打开cmd,输入sqlite3

 命令 .help 帮助

         .exit 退出程序

数据库管理

//创建数据库,
sqlite3 test.db
//创建一个表,此时才会创建数据库
create table test (id integer primary key, value text);
//向表中插入几行数据
insert into test (id ,value ) values(1,'eenie');
insert into test (id ,value ) values(2,'meenie');
insert into test (value) values ('miny');
insert into test (value) values ('mo');
//返回插入内容
.mode column
.headers on
select * from test;
//获得最后插入的自动增量值
select last_insert_rowid();
//添加一个索引和视图
create index test_idx on test (value);
create view schema as select *from sqlite_master;
//退出
.exit

猜你喜欢

转载自www.cnblogs.com/restpain/p/9728859.html