1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Railsでコンソールを使ってDBをいじる

1
Posted at

1) rails c の場合

rails cでrailsのコンソールに入れる. コンソールに入ったら, 各モデルのメソッドを使ってDB検索などができる.

User.all
=> SELECT `users`.* FROM `users`

メソッドはこちらにまとまってる
http://qiita.com/tono0123/items/576a4a4659b51860f304

2) rails db の場合

rails db でDBのクライアントをコンソール画面でいじれるようになる. DBのクライアントなので, SQL文が使える.

SELECT * FROM USERS;

以上.

1
2
0

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
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?