遇有未知結構的數據庫時,可以通過以下方法來或許數據庫中詳細信息。
1. .table命令 可以查詢當前數據庫中所有的表名
2. select * from sqlite_master WHERE type = "table"; 可以查詢到當前數據庫中所有表的詳細結構信息
[test@localhost ~]$ sqlite3 py.db
SQLite version 3.6.17
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .table
py_phrase py_pinyin py_shengmu
sqlite> select * from sqlite_master WHERE type = "table";
table|py_pinyin|py_pinyin|2|CREATE TABLE py_pinyin (pinyin TEXT PREMARY KEY)
table|py_shengmu|py_shengmu|3|CREATE TABLE py_shengmu (shengmu TEXT PREMARY KEY)
table|py_phrase|py_phrase|4|CREATE TABLE py_phrase (
ylen INTEGER,
y0 INTEGER, y1 INTEGER, y2 INTEGER, y3 INTEGER, yx TEXT,
s0 INTEGER, s1 INTEGER, s2 INTEGER, s3 INTEGER,
phrase TEXT,
freq INTEGER, user_freq INTEGER)
sqlite>
1)創建數據庫文件:
>SQLite3 d:\test.db 回車
就生成了一個test.db在d盤。
這樣同時也SQLite3掛上了這個test.db
2)
用.help可以看看有什么命令
>.help 回車即可
3)可以在這里直接輸入SQL語句創建表格 用;結束,然后回車就可以看到了
4)看看有創建了多少表
>.tables
5)看表結構
>.schema 表名
6)看看目前掛的數據庫
>.database
7)如果要把查詢輸出到文件
>.output 文件名
> 查詢語句;
查詢結果就輸出到了文件c:\query.txt
把查詢結果用屏幕輸出
>.output stdout
8)把表結構輸出,同時索引也會輸出
.dump 表名
9)退出
>.exit 或者.quit
普通SQL操作,通用標準SQL語句。