Oracle SQL Oracle SQL SELECT Statements 2 — Questions and Answers
Question 1: What does the DUAL table represent in Oracle SQL?
- A temporary table for joins
- A special one-row, one-column table used for evaluating expressions (Correct answer)
- A backup of the main table
- A table containing dual primary keys
Correct answer: A special one-row, one-column table used for evaluating expressions
DUAL is a special Oracle table with one row and one column, used to evaluate expressions or call functions without referencing a real table.
Question 2: Which Oracle SQL clause is used to eliminate groups that don't meet a condition after GROUP BY?
- WHERE
- HAVING (Correct answer)
- EXCLUDING
- FILTER BY
Correct answer: HAVING
HAVING filters grouped rows based on aggregate conditions, while WHERE filters individual rows before grouping.
Question 3: What is the result of dividing a number by zero in Oracle SQL?
- Returns NULL
- Returns 0
- Raises an ORA-01476 error (Correct answer)
- Returns Infinity
Correct answer: Raises an ORA-01476 error
Oracle raises ORA-01476 'divisor is equal to zero' error when a division by zero occurs in a query.
Question 4: In a SELECT statement, which order do clauses execute logically in Oracle SQL?
- SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY
- FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY (Correct answer)
- WHERE → FROM → SELECT → GROUP BY → ORDER BY → HAVING
- FROM → SELECT → WHERE → HAVING → GROUP BY → ORDER BY
Correct answer: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY
Oracle processes clauses in this logical order: FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY, even though SELECT is written first.
Question 5: Which Oracle SQL function returns the current date and time including seconds?
- SYSDATE (Correct answer)
- CURRENT_DATE
- NOW()
- GETDATE()
Correct answer: SYSDATE
SYSDATE returns the current date and time from the database server, including hours, minutes, and seconds.
Question 6: What does the BETWEEN operator do in Oracle SQL?
- Checks if a value is NULL
- Checks if a value falls within an inclusive range (Correct answer)
- Compares two strings for equality
- Returns rows between two tables
Correct answer: Checks if a value falls within an inclusive range
BETWEEN tests whether a value is within a range inclusively, equivalent to value >= lower AND value <= upper.
What does the DUAL table represent in Oracle SQL?