FrontPage > DataBase > SQLite > sqliteコマンド
SQLiteは、「型(TYPE)」の区別が無いので
どんな「型(TYPE)」、「サイズ等」の指定しても内部的には「文字列型」になります。
そのため、「型」、「サイズ等」の指定は省略可能です。
「number(5)」で作成した項目に 「"あいうえおかきくけこ"」などが登録(insert等)出来てしまいます。
$ sqllite [データベース・ファイル名] ※ファイルが無い場合に自動生成されます。 ※createdb(PostgreSQL)、「create database」コマンド等不要。
sqlite> SELECT TYPE, NAME, TBL_NAME, ROOTPAGE FROM SQLITE_MASTER;
sqlite> .schema
sqlite> .schema [テーブル名]
sqlite> PRAGMA TABLE_INFO([テーブル名]);
sqlite> .exit
テーブル作成 (sequenceは、"integer primary key"を追加) sqlite> create table hoge ( seq integer primary key, hoge_comment); データ作成 (seq項目をnull化する。) sqlite> insert into hoge (hoge_comment) values ('hoge comment'); sqlite> insert into hoge values (null, 'hoge comment'); データの確認 sqlite> select * from hoge; 1|hoge comment 2|hoge comment
.bail ON|OFF Stop after hitting an error. Default OFF [V3] .databases List names and files of attached databases .dump ?TABLE? ... Dump the database in a text format .echo ON|OFF Turn command echo on or off .exit Exit this program .explain ON|OFF Turn output mode suitable for EXPLAIN on or off. .header(s) ON|OFF Turn display of headers on or off .help Show this message .import FILE TABLE Import data from FILE into TABLE [V3] .indices TABLE Show names of all indices on TABLE .load FILE ?ENTRY? Load an extension library [V3] .mode MODE Set mode to one of "line(s)", "column(s)","insert", "list", or "html" [V2] .mode MODE ?TABLE? Set output mode where MODE is one of: [V3] csv Comma-separated values column Left-aligned columns. (See .width) html HTML <table> code insert SQL insert statements for TABLE line One value per line list Values delimited by .separator string tabs Tab-separated values tcl TCL list elements .mode insert TABLE Generate SQL insert statements for TABLE [V2] .nullvalue STRING Print STRING instead of nothing for NULL data .output FILENAME Send output to FILENAME .output stdout Send output to the screen .prompt MAIN CONTINUE Replace the standard prompts .quit Exit this program .read FILENAME Execute SQL in FILENAME .schema ?TABLE? Show the CREATE statements .separator STRING Change separator string for "list" mode .show Show the current values for various settings .tables ?PATTERN? List names of tables matching a pattern .timeout MS Try opening locked tables for MS milliseconds .width NUM NUM ... Set column widths for "column" mode