SQL 문에 주석 추가

적용 대상:check marked yes Databricks SQL check marked yes Databricks 런타임

주석은 SQL 코드를 문서화하고 SQL 코드를 일시적으로 사용하지 않도록 설정하는 데 유용합니다.

문 앞, 후 및 문 내에서 SQL 코드에 주석을 추가할 수 있습니다. 주석은 힌트로 인식되지 않는 한 Azure Databricks에서 무시됩니다.

지원되는 주석 형식은 다음과 같습니다.

간단한 설명

간단한 주석은 텍스트의 전체 줄 또는 텍스트 줄의 다시기본der를 포함하는 데 사용됩니다.--

구문

-- text

매개 변수

  • text: EOL(줄 끝) 문자를 제외한 모든 텍스트(예: \n.)

예제

> -- 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 */