The output of the query " Select length(substr('SQL Functions',-10,12)) from dual; " is
-
12
-
10
-
13
-
error
Reveal answer
Fill a bubble to check yourself
B
Correct answer
Explanation
In Oracle SQL, substr('SQL Functions', -10, 12) extracts a substring starting 10 characters from the end (' Functions') with a length of 12. Since only 10 characters remain, it returns ' Functions'. The length of this string is 10, making 10 the correct output.
AI explanation
To answer this question, let's break down the query step by step:
The query is:
Select length(substr('SQL Functions',-10,12)) from dual;
- The
substrfunction is used to extract a substring from the given string'SQL Functions'. The parameters are(string, start_position, length). - In this case,
substr('SQL Functions',-10,12)will extract a substring starting from the 10th position from the end (-10) and with a length of 12 characters. So, the extracted substring is' Functions'. - The
lengthfunction is then applied to the extracted substring' Functions', which returns the length of the string. - Finally, the result of the query is the length of the extracted substring, which is 10.
Therefore, the correct answer is B) 10.