SQL ステートメントへのコメントの追加

適用対象:check marked yes Databricks SQL check marked yes Databricks Runtime

コメントは、SQL コードを文書化したり、SQL コードを一時的に無効にしたりするのに役立ちます。

SQL コードには、ステートメントの前、後、およびステートメント内にコメントを追加できます。 コメントは、ヒントとして認識されない限り、Azure Databricks によって無視されます。

次の形式のコメントがサポートされています。

単純なコメント

単純なコメントは、テキスト行全体、または -- で始まるテキスト行の残りの部分をカバーするために使用されます

構文

-- text

パラメーター

  • text: \n などの行末 (EOL) 文字を除く任意のテキスト。

> -- This is a comment

> SELECT 1; -- This is also a comment
  1

> SELECT -- This is a comment
 1;
  1

> SELECT -- Comments are not limited to Latin characters: 评论 😊
 1;
  1

> SELECT '-- This is not a comment';
  -- This is not a comment

> SELECT -- This is a bad comment because the "one" should be on the next line... 1
 Syntax error

> SELECT -- this is a bad
comment because it contains an EOL character
  1;
 Syntax error

角かっこで囲まれたコメント

角かっこで囲まれたコメントは、複数行のテキストまたはテキスト行の一部をカバーするために使用されます。

構文

bracketed_comment
  /* text [ bracketed_comment [...] ] text */

パラメーター

  • text: /* および */ を除く、行末 (EOL) 文字を含む任意のテキスト。

> /* This is a comment */

> SELECT 1; /* This is also a comment */

> SELECT /* This is a comment
  that spans multiple lines */ 1;

> SELECT /* Comments are not limited to Latin characters: 评论 😊 */ 1;

> SELECT /* Comments /* can be */ nested */ 1;

> SELECT /* Quotes in '/*' comments "/*" are not special */ */ */ 1;

> /* A prefixed comment */ SELECT 1;

> SELECT '/* This is not a comment */';
  /* This is not a comment */