15.00 - Comments - Teradata Database

Teradata Database SQL Fundamentals

prodname
Teradata Database
vrm_release
15.00
category
Programming Reference
featnum
B035-1141-015K

Comments

You can embed comments within an SQL request anywhere a pad character can occur.

The SQL Parser and the preprocessor recognize the following types of ANSI/ISO SQL:2011-compliant embedded comments:

  • Simple
  • Bracketed
  • Simple Comments

    The simple form of a comment is delimited by two consecutive HYPHEN-MINUS (U+002D) characters (--) at the beginning of the comment and the newline character at the end of the comment.

    The newline character is implementation-specific, but is typed by pressing the Enter (non-3270 terminals) or Return (3270 terminals) key.

    Simple SQL comments cannot span multiple lines.

    Examples  

    The following examples illustrate the use of a simple comment at the end of a line, at the beginning of a line, and at the beginning of a statement:

       SELECT EmpNo, Name FROM Payroll_Test
       ORDER BY Name -- Simple comment at the end of a line
       ;
     
       SELECT EmpNo, Name FROM Payroll_Test
       -- Simple comment at the beginning of a line
       ORDER BY Name;
     
       -- Simple comment at the beginning of a statement
       SELECT EmpNo, Name FROM Payroll_Test
       ORDER BY Name;

    Bracketed Comments

    A bracketed comment is a text string of unrestricted length that is delimited by the beginning comment characters SOLIDUS (U+002F) and ASTERISK (U+002A) /* and the end comment characters ASTERISK and SOLIDUS */.

    Bracketed comments can begin anywhere on an input line and can span multiple lines.

    Examples  

    The following examples illustrate the use of a bracketed comment at the end of a line, in the middle of a line, at the beginning of a line, and at the beginning of a statement:

       SELECT EmpNo, Name FROM Payroll_Test /* This bracketed comment starts
                                               at the end of a line
                                               and spans multiple lines. */
       ORDER BY Name;
     
       SELECT EmpNo, Name FROM Payroll_Test 
       /* This bracketed comment starts
          at the beginning of a line
          and spans multiple lines. */
       ORDER BY Name;
     
       /* This bracketed comment starts
          at the beginning of a statement
          and spans multiple lines. */
       SELECT EmpNo, Name FROM Payroll_Test 
       ORDER BY Name;
     
       SELECT EmpNo, Name 
       FROM  /* This comment is in the middle of a line. */ Payroll_Test
       ORDER BY Name;
     
       SELECT EmpNo, Name FROM Payroll_Test /* This bracketed 
          comment starts at the end of a line, spans multiple 
          lines, and ends in the middle of a line. */ ORDER BY Name;
     
       SELECT EmpNo, Name FROM Payroll_Test 
       /* This bracketed comment starts at the beginning of a line,
          spans multiple lines, and ends in the 
          middle of a line. */ ORDER BY Name;

    Comments With Multibyte Character Set Strings

    You can include multibyte character set strings in both simple and bracketed comments.

    When using mixed mode in comments, you must have a properly formed mixed mode string, which means that a Shift-In (SI) must follow its associated Shift-Out (SO).

    If an SI does not follow the multibyte string, the results are unpredictable.

    When using bracketed comments that span multiple lines, the SI must be on the same line as its associated SO. If the SI and SO are not on the same line, the results are unpredictable.

    You must specify the bracketed comment delimiters (/* and */) as single byte characters.