LoginSignup
57
47

More than 5 years have passed since last update.

MySQLでテーブル一覧とカラム一覧を同時に取ってくる

Last updated at Posted at 2017-01-19

ググってもなかなかヒットしないのでまとめておく。
(「同時に」、とか「一緒に」、とか、ニーズないのかなぁ…)

ここを参考にした
mysqlで全テーブルのカラム一覧を見たい

テーブル一覧だけを取ってくる

show tables from 'DB名';

各テーブルのカラム一覧を取ってくる

show columns from 'テーブル名';

テーブル一覧と、そのテーブルのカラム一覧を同時に取ってくる

直接ではなく、information_schemaというところを使う。

use information_schema;
select table_name, column_name from columns where table_schema="DB名";
57
47
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
57
47