SQLite3のインストール

Windows

ここでは、Windows用のSQLite3 CLIをインストールする。

  1. http://www.sqlite.org/download.html からWindows用Precompiled Binary(sqlite-3_5_9.zip)をダウンロード
  2. 任意の場所にsqlite-3_5_9.zipを展開(内容はsqlite3.exeのみ)

使い方サンプル

  • D:\work\testdb というデータベースファイルに対するコマンドライン操作の例
D:\work>sqlite3 testdb          <- testdbを開く(testdbが存在しないと作成される)
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .database               <- オープンしているデータベースの確認
seq  name             file
---  ---------------  ----------------------------------------------------------
0    main             D:\work\testdb

sqlite> create table hoge(      <- hogeテーブルの作成
   ...>     id int,
   ...>     name varchar(255)
   ...> );
sqlite>
sqlite> .table                  <- テーブル一覧の表示
hoge
sqlite> .schema hoge            <- hogeテーブルの構造の表示
CREATE TABLE hoge(
    id int,
    name varchar(255)
);
sqlite> insert into hoge(id,name) values(1,'foo');   <- hogeテーブルに一行挿入
sqlite>
sqlite> select * from hoge;      <- hogeテーブルを検索
1|foo
sqlite> .quit                    <- sqlite3終了

みたいな感じで