Multiple choice technology databases

Which of the query will print the output as 'TCS' (single quotes should come in the output)

  1. select ' ' ' || 'TCS' || ' ' ' from dual

  2. select ' ' 'TCS' ' ' from dual

  3. select 'TCS' from dual

  4. select "TCS" from dual

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In Oracle SQL, to include a single quote in a string literal, you escape it by doubling it. The string ' ' 'TCS' ' ' actually parses as: quote-space-quote (space), then 'TCS', then quote-space-quote (space). The doubled quotes represent literal single quote characters. Option B correctly uses this escaping.

AI explanation

In Oracle you escape a single quote inside a string literal by doubling it. SELECT '''TCS''' FROM dual parses as: open quote, '' (one literal '), TCS, '' (one literal '), close quote — producing the output 'TCS'. Option B is this query, so it is correct; option A adds broken concatenation and options C/D omit the quotes.