Oracle Database SQL — Question 71
Examine this query:
SELECT SUBSTR(SYSDATE, 1, 5) "Result" FROM DUAL;
Which statement is true?
Answer options
- A. It fails unless the expression is modified to SUBSTR(TO_CHAR(SYSDATE), 1, 5).
- B. It fails unless the expression is modified to SUBSTR(TO_CHAR(TRUNC(SYSDATE), 1, 5).
- C. It fails unless the expression is modified to TO_CHAR(SUBSTR(SYSDATE), 1, 5)).
- D. It executes successfully with an implicit data type conversion.
Correct answer: D
Explanation
The query executes successfully because Oracle performs an implicit data type conversion from a date to a string when using the SUBSTR function. The other options suggest modifications that are not necessary, as the query does not actually fail due to the implicit conversion that takes place.