LoginSignup
26
21

More than 5 years have passed since last update.

Sublime Text でSQLを整形する

Last updated at Posted at 2014-12-25

改行などが全くない長〜いSQLは、Sublime Text のプラグイン SQL Beautifier を使って読みやすく整形できます。

※同様の用途で FormatSQL というプラグインもありますが、こちらは私の環境ではうまく動きませんでした。

使い方

  1. Sublime Text にプラグイン SQL Beautifier をインストールします。
  2. 整形したいSQLを Sublime Text に貼り付けます。
  3. super+k, super+f キーを押します。(Windows/Linux だと ctrl+K, ctrl+f)
  4. できあがり

こんな感じに整形されます

使用前

player.sql
select name, job, level, exp, gold, gender from player where id = 12345 and update_date > '2014-12-01';

使用後

player.sql
SELECT name, job, LEVEL, exp,
                         gold,
                         gender
FROM player
WHERE id = 12345 and
      update_date > '2014-12-01';
26
21
2

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
26
21