LoginSignup
45

More than 3 years have passed since last update.

posted at

updated at

Organization

RailsのローカルでSQLiteを使う時

RailsのローカルでSQLiteを使う

Railsアプリケーションを触っている時に本番環境はPostgreSQLだけど
ローカルはSQLiteだったって時に

接続する

$ sqlite3 db/development.sqlite3

もしくは

$ rails db

で接続できます!

データベース一覧

sqlite> .databases

これでデータベースの一覧を確認

テーブル一覧

sqlite> .tables

これでテーブル一覧を取得

SQL文

sqlite> select * from user;

もちろんSQL文もそのまま打てます!

スキーマ表示

sqlite> .schema users 

スキーマのデーブルも確認できます!

テーブルの中のカラム確認

sqlite> PRAGMA TABLE_INFO(TABLE_NAME); 

テーブルのカラムを確認できます!

終了

sqlite> .exit

これで終了

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
45