Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

Are there multiline comment delimiters in SQL that are vendor agnostic?

While editing, building up, or cherry picking from SQL statements I can find myself interacting with one of four popular database tools. I have been resorting to single line commenting for DB2 and Informix. I have created macros in vim to make this slightly more efficient but I was wondering if I am working too hard.

question from:https://stackoverflow.com/questions/728172/are-there-multiline-comment-delimiters-in-sql-that-are-vendor-agnostic

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

C style comments are standard in SQL 2003 and SQL 2008 (but not in SQL 1999 or before). The following DBMS all support C style comments:

  • Informix
  • PostgreSQL
  • MySQL
  • Oracle
  • DB2
  • Sybase
  • Ingres
  • Microsoft SQL Server
  • SQLite (3.7.2 and later)
  • Teradata and Aster

That is not every possible DBMS, but it is more or less every major SQL DBMS. (I'll willingly add notes about any other DBMS that does - or does not - support C style comments.)

The SQL 2003 standard documents comment notations thus:

<comment> ::= <simple comment> | <bracketed comment>

<simple comment> ::=
    <simple comment introducer> [ <comment character> ... ] <newline>

<simple comment introducer> ::=
    <minus sign> <minus sign> [ <minus sign> ... ]

<bracketed comment> ::=
    <bracketed comment introducer> <bracketed comment contents>
    <bracketed comment terminator>

<bracketed comment introducer> ::= <slash> <asterisk>

<bracketed comment terminator> ::= <asterisk> <slash>

<bracketed comment contents> ::= [ { <comment character> | <separator> }... ]

<comment character> ::= <nonquote character> | <quote>

IBM Informix Dynamic Server (IDS or Informix) supports C style comments. It also supports '{ ... }' as potentially multi-line comments, except in contexts where it means something else - that something else being a LIST or SET or MULTISET literal. (You might find that DB-Access gets confused by C style comments; that is a separate issue.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...