LoginSignup
1
0

More than 1 year has passed since last update.

MysqlとPostgreSQLのコマンドの比較

Posted at

背景

普段の業務ではMysqlで開発することが多いですが、他社で作られたシステムの保守を引き継いだり等で、稀にPostgreSQLを使う機会があります。
その際、毎回「あれ、PostgreSQLのこのコマンド何だったっけ?」と調べる羽目になるので、忘れがちなコマンドをまとめました。

MysqlとPostgreSQLのコマンドの比較

データベース一覧

Mysqlの場合

show databases;

PostgreSQLの場合

\l

テーブル一覧

Mysqlの場合

show tables;

PostgreSQLの場合

\dt

テーブル定義

Mysqlの場合

show columns from [table_name];

PostgreSQLの場合

\d [table_name]

インデックス一覧

Mysqlの場合

show index from [table_name];

PostgreSQLの場合

\d [table_name]

最後に

他にも両者で違うコマンドは多々あるのですが、比較的業務で使用頻度が高く、かつ忘れがちなコマンドに絞ってまとめました。
こういうの聞かれたら何も見ないでさっと答えられるようになるのが理想なのですが、なかなか難しいものです。

1
0
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
0