在调试应用的时候,可以查看数据库里的数据。
1、定位到模拟器的目录
cd ~/Library/Application\ Support/iPhone\ Simulator
2、查找文件名包含
OrgChart.sqlite
的文件,并打印路径
find . -name "OrgChart.sqlite" –print
输出:
./5.0/Applications/E8654A34-8EC4-4EAF-B531-00A032DD5977/Documents/OrgChart.sqlite
3、进入SQLite的shell
sqlite3 ./5.0/Applications/E8654A34-8EC4-4EAF-B531-00A032DD5977/Documents/OrgChart.sqlite
执行后显示为:
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
4、显示SQL schema
sqlite> .schema
执行后显示为:
CREATE TABLE ZORGANIZATION ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZID
INTEGER, ZLEADER INTEGER, ZNAME VARCHAR );
CREATE TABLE ZPERSON ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZID
INTEGER, Z2EMPLOYEES INTEGER, ZNAME VARCHAR );
CREATE TABLE Z_METADATA (Z_VERSION INTEGER PRIMARY KEY, Z_UUID VARCHAR(255), Z_PLIST
BLOB);
CREATE TABLE Z_PRIMARYKEY (Z_ENT INTEGER PRIMARY KEY, Z_NAME VARCHAR, Z_SUPER INTEGER,
Z_MAX INTEGER);
CREATE INDEX ZORGANIZATION_ZLEADER_INDEX ON ZORGANIZATION (ZLEADER);
CREATE INDEX ZPERSON_Z2EMPLOYEES_INDEX ON ZPERSON (Z2EMPLOYEES);
5、查询
sqlite> select Z_PK, ZID, ZLEADER, ZNAME from ZORGANIZATION;
执行后显示为:
1|-19904|2|MyCompany, Inc.
6、查看tables
sqlite> .tables
7、退出
sqlite> .quit
其他命令参见“.help”。
本文转载自:http://www.cnblogs.com/submarine/archive/2012/09/28/2707734.html