nerdexam
EC-Council

312-50V10 · Question #342

Which of the following is used to indicate a single-line comment in structured query language (SQL)?

The correct answer is A. --. In SQL, a double hyphen (--) begins a single-line comment, causing the database engine to ignore everything after it on that line.

SQL Injection

Question

Which of the following is used to indicate a single-line comment in structured query language (SQL)?

Options

  • A--
  • B||
  • C%%
  • D''

How the community answered

(24 responses)
  • A
    88% (21)
  • B
    4% (1)
  • D
    8% (2)

Why each option

In SQL, a double hyphen (--) begins a single-line comment, causing the database engine to ignore everything after it on that line.

A--Correct

The ANSI SQL standard defines -- as the single-line comment delimiter; any text following -- on the same line is ignored by the SQL parser. This syntax is supported across major RDBMS platforms including SQL Server, Oracle, MySQL, and PostgreSQL, and is also commonly exploited in SQL injection attacks to truncate or neutralize the remainder of a query.

B||

|| is the standard SQL string concatenation operator (used in Oracle, PostgreSQL, and ANSI SQL) and has no comment-related function.

C%%

%% is not valid SQL syntax; a single % is used as a wildcard character within LIKE predicate patterns, not for comments.

D''

'' represents an empty string literal in SQL and has no comment functionality.

Concept tested: SQL single-line comment syntax and injection

Source: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/comment-transact-sql

Topics

#SQL comment syntax#single-line comment#SQL injection basics#query structure

Community Discussion

No community discussion yet for this question.

Full 312-50V10 Practice