169
137

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.

SequelProでER図を出力する方法

Posted at

MySQLのMac用GUI無料クライアントのSequel ProでER図を出す方法です。

こんな感じのER図が出せます。

graphvizを入れとく

brew install graphviz

dotファイルをエクスポートする

Sequel Proで File > Export… > Dot を出力形式で選択 > Export。

dotファイルをpngに変換する

dot -Tpng localhost-db.dot > localhost-db.png

以上。

今回使ったDBのDDL

ちなみに今回出力してみたDBのDDLは次になります。

-- Create syntax for TABLE 'categories'
CREATE TABLE `categories` (
  `id` mediumint(8) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create syntax for TABLE 'items'
CREATE TABLE `items` (
  `id` int(11) unsigned NOT NULL,
  `category_id` mediumint(8) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `category_id` (`category_id`),
  CONSTRAINT `items_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
169
137
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
169
137

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?