Oracle SQL Oracle SQL Functions 1 — Questions and Answers
Question 1: Which Oracle SQL function converts a string to uppercase?
- INITCAP
- UPPER (Correct answer)
- CAPITALIZE
- UCASE
Correct answer: UPPER
The UPPER function converts all characters in a string to uppercase letters.
Question 2: What does the NVL function do in Oracle SQL?
- Returns NULL if both arguments are equal
- Replaces a NULL value with a specified substitute value (Correct answer)
- Counts non-NULL values
- Converts a number to NULL
Correct answer: Replaces a NULL value with a specified substitute value
NVL(expr, replacement) returns the replacement value when expr is NULL, otherwise returns expr unchanged.
Question 3: Which Oracle SQL function returns the number of characters in a string?
- SIZE
- LEN
- LENGTH (Correct answer)
- STRLEN
Correct answer: LENGTH
The LENGTH function returns the number of characters in a string, or NULL if the string is NULL.
Question 4: What does the ROUND function do in Oracle SQL when called as ROUND(45.678, 1)?
- Returns 45
- Returns 45.7 (Correct answer)
- Returns 46
- Returns 45.68
Correct answer: Returns 45.7
ROUND(45.678, 1) rounds to one decimal place, returning 45.7.
Question 5: Which Oracle SQL function extracts a portion of a string starting at a given position?
- MID
- SUBSTR (Correct answer)
- LEFT
- EXTRACT
Correct answer: SUBSTR
SUBSTR(string, start, length) extracts a substring starting at the given position for a specified number of characters.
Question 6: What does the TRUNC(45.789) function return in Oracle SQL?
- 46
- 45.8
- 45 (Correct answer)
- 45.79
Correct answer: 45
TRUNC without a second argument removes all decimal places, returning the integer portion 45 without rounding.
Which Oracle SQL function converts a string to uppercase?