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

To output literal single quotes around TCS, use two consecutive single quotes: '''TCS'''. In Oracle SQL, a single quote within a string is escaped by doubling it. The outer quotes define the string, inner pairs become literal quotes in output.

AI explanation

In Oracle SQL, a literal single quote inside a quoted string is escaped by doubling it. So '''TCS''' is parsed as: opening quote, then '' (an escaped literal single quote → renders as '), then TCS, then another '' (another escaped quote → '), then the closing quote — producing the output 'TCS' complete with surrounding single quotes. The option with double quotes ("TCS") would just select the identifier/column alias TCS or error, not produce quote characters in the output. select 'TCS' from dual outputs TCS with no quotes. The garbled option with '||'TCS ||''' has mismatched/invalid quote syntax and would raise an error.