データベースは初めてです。今私はsqliteをlearmするつもりです。sqliteシェル3.7.14.1をダウンロードしました。私は長い間これをグーグルで検索するデータベースを作成しようとしています。しかし、答えを見つけることができません。
シェルでコマンドsqlite3 test.db
を実行すると表示され...>
、コマンドで終了し.exit
ますが、データベースが作成されていないことがわかります。誰かがこの問題で私を助けてくれませんか。
の
...>
SQLite からの行継続プロンプトです。代わりに、以下の手順に従ってください。
$ sqlite3 test.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table test (n integer primary key);
sqlite> .quit
$ ls test.db
test.db
SQL 文字列を SQLite にパイプすることもできます。
$ echo "create table test_2 (n integer primary key);" | sqlite3 test.db
そして、あなたはこのようにテーブルを見ることができます。
$ sqlite3 test.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
test test_2
または、SQL 文字列を引数として sqlite3 実行可能ファイルに指定します。
$ sqlite3 test.db "create table test3 (n integer primary key);"
作成されていませんか?
.databases
確認するためにsqlliteコマンドを試してください
コマンド:
sqlite3 test.db
というファイルにデータベースが作成されますtest.db
。テーブルの作成に進むと、このデータベースのデータを保存してクエリを実行できるようになります。
これを試して:
sqlite3 test.db "create table test_table (someid INTEGER PRIMARY KEY, somedata TEXT);"
sqlite3 test.db "insert into test_table values (1, 'Some Text');"
それから
sqlite3 test.db "select * from test_table;"
Windows での「セッション」の例を次に示します。