Ubuntu12.04 SQLite安装

参考:

http://linux.cn/portal-view-aid-613.html

1、 安装SQLite3   
       hadron@hadron ~ $ sudo apt-get install sqlite sqlite3
2、 查看版本号   
       hadron@hadron ~ $ sqlite3 -version
3、 创建test数据库
       hadron@hadron ~ $ sqlite3 test.db    
       SQLite version 3.7.9 2011-11-01 00:52:41
       Enter ".help" for instructions
       Enter SQL statements terminated with a ";"
       sqlite> 
4、 查看数据库
       sqlite> .database
       seq  name             file                                                      
       ---  ---------------  ----------------------------------------------------------
       0    main             /home/hadron/test.db                                      
5、 创建数据表
       sqlite> create table user(id,username,password);
6、 插入数据
       sqlite> insert into user(id,username,password) values(1,'abc','123');
7、 查询数据
       sqlite> select * from user;
       1|abc|123
8、 退出数据库
       sqlite> .exit
9、 再次进入数据库
       hadron@hadron ~ $ sqlite3
      SQLite version 3.7.9 2011-11-01 00:52:41
      Enter ".help" for instructions
      Enter SQL statements terminated with a ";"
      sqlite> 
10、安装可视化工具:
      hadron@hadron ~ $ sudo apt-get install sqlitebrowser


这个region.db是我导入的,其中三个表t_provinces  t_cities 是有索引的,通过.indices命令可以查看。

至于索引的建立,我是登录sqlite后,利用SQL语句建立的:

create index my_index on my_table(id, user_id);

相应地,drop index和reindex来维护索引。


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值