LoginSignup
0
0

More than 3 years have passed since last update.

SQLでカラム名からテーブル名を割り出す方法

Posted at

環境

MySQL

やりたいこと

カラムからどこのテーブルにあるのか知りたい。

コード

> SELECT table_name, column_name FROM information_schema.columns WHERE column_name = "<カラム名>";

解説

information_shema.columns というテーブルに、カラムに関する情報が詰まっているので、そこから逆引きをする。

興味がある人は「show columns from information_schema.columns」とかで中身を見てみると面白いですよ!!

最後に

私はよく使うので、Clipyのスニペットに登録しています。

option + s で、SQLでよく使う系のやつをまとめて登録してます^^

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