天天看點

java mysql查詢資料庫表結構_SQLITE查詢資料庫表結構

遇有未知結構的資料庫時,可以通過以下方法來或許資料庫中詳細資訊。

1.   .table指令  可以查詢目前資料庫中所有的表名

2.   select * from sqlite_master WHERE type = "table";   可以查詢到目前資料庫中所有表的詳細結構資訊

[[email protected] ~]$ 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語句。

posted on 2010-01-10 22:41 江天部落格 閱讀(5163) 評論(0)  編輯  收藏 所屬分類: Android