Which of the query will print the output as 'TCS' (single quotes should come in the output)
-
select '''||'TCS ||''' from dual
-
select '''TCS''' from dual
-
select "TCS" from dual
-
select 'TCS' from dual
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.
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.