SQLite 資料一覧

データベース/テーブルに関する情報取得

2008/4/10更新

対応バージョン: 3.5.4

データベースやテーブルに関する情報はSQLiteの管理コマンド(先頭が「.」で始まる)で取得できる。

以下、主なものについて説明する。

.databases

接続中のデータベースの名前とファイル名の一覧を表示する。

sqlite> .databases
seq  name       file
---  ---------  --------------------------------
0    main       /home/foo/test.db

.tables [<パターン>]

テーブルの一覧を表示する。引数でテーブル名のパターンを指定可能。

sqlite> .tables
customer  purpose 

sqlite> .tables tom
customer

.schema [<パターン>]

テーブル定義(*)を表示する。引数でテーブル名のパターンを指定可能。

sqlite> .schema customer
CREATE TABLE customer(
id integer,
name text,
tel text,
address text);

(*) 正確にいうとテーブルを定義する際のCREATE文

.indices <テーブル>

指定したテーブルに関する全てのインデックス名を表示する。

sqlite> .indices foo
foo_idx_1