Ruby on RailsでDBをマイグレーションした際にテーブルの更新内容確認のため使用した。手軽な確認操作のため忘備録として残しておく。
注)PostgreSQL利用時の操作になる。
1. DBコンソールを起動
1 |
$ rails db |
2.テーブルの詳細確認
コンソールが起動したら、「\d [テーブル名];」でテーブル詳細を確認。(下記例はusersテーブル)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
db_development=# \d users; Table "public.users" Column | Type | Collation | Nullable | Default -----------------+-----------------------------+-----------+----------+----------------------------------- id | bigint | | not null | nextval('users_id_seq'::regclass) name | character varying | | not null | email | character varying | | not null | password | character varying | | not null | created_at | timestamp without time zone | | not null | updated_at | timestamp without time zone | | not null | admin | boolean | | not null | false Indexes: "users_pkey" PRIMARY KEY, btree (id) "index_users_on_email" UNIQUE, btree (email) |
型やNOT NULL制約の確認もできる。手軽なのでお試しあれ。