赞
踩
http://blog.csdn.net/guoxu775/article/details/7569110
前提:已经配置好adb,sqlite的环境变量
1. 启动模拟器
2. cmd—— adb shell(进入shell命令,就是操作linux)
3. 找到要查看的表目录
eg. 项目的包名为:com.kee.test,
则目录为:data/data/com.kee.test/databases
数据库:test_db.db
4. 启动sqlite3,并指定数据库:
sqlite3 test_db.db
5. select * from mytable;
在 # 提示符下输入以下命令,我们进入sqlite(Figure3)。
sqlite3 StudDB.db
这个命令会打开StudDB.db数据库,若StudDB.db数据库不存在,则会新建一个名为
StudDB.db的数据库。(注意数据库名大小写有区别)
select * from Student;
我们查出三条数据。这个数据库的显示方式让我们习惯了Oralce,看得很不舒服,输入
以下两个命令,让我们改变这种显示模式。
在#提示符下输入exit退出Linux。
个网站关于SQL用法有非常有趣的图示
1, "show tables" in sqlite
命令行模式
.schema 抓出数据库中所有的表
.tables 抓出数据库中所有的表和索引
都可以使用LIKE来匹配
程序中查看
使用sqlite中的sqlite_master表来查询
sqlite_master表结构
CREATE TABLE sqlite_master (
type TEXT,
name TEXT,
tbl_name TEXT,
rootpage INTEGER,
sql TEXT
);
查询table,type 段是'table',name段是table的名字, so:
select name from sqlite_master where type='table' order by name;
查询indices,type段是'index', name 是index的名字,tbl_name是index所拥有的table的名字
2.查看表结构"describe table"
cursor.execute("PRAGMA table_info(tablename)")
print cursor.fetchall()
here is a command available for this on the sqlite command line.
.tables ?PATTERN? List names of tables matching a LIKE pattern
Which converts to the following SQL
- SELECT name FROM sqlite_master
- WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%'
- UNION ALL
- SELECT name FROM sqlite_temp_master
- WHERE type IN ('table','view')
- ORDER BY 1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。