1Z0-006 Basic SQL Statements 4 — Questions and Answers
Question 1: In Oracle SQL, which pseudo-table is used when you want to SELECT an expression or function without referencing a real table?
- SYSDATE
- DUAL (Correct answer)
- ROWNUM
- SYS
Correct answer: DUAL
DUAL is a special one-row, one-column dummy table in Oracle used to evaluate expressions that don't require a real table.
Question 2: What does the BETWEEN operator include in its range?
- Only the lower bound
- Only the upper bound
- Both the lower and upper bounds (Correct answer)
- Neither bound
Correct answer: Both the lower and upper bounds
BETWEEN x AND y is inclusive; it matches values greater than or equal to x AND less than or equal to y.
Question 3: Which of the following correctly inserts a row with specific column values?
- INSERT EMPLOYEES VALUES (101, 'Ana');
- INSERT INTO EMPLOYEES VALUES (101, 'Ana'); (Correct answer)
- INSERT INTO EMPLOYEES SET id=101, name='Ana';
- ADD INTO EMPLOYEES (id, name) VALUES (101, 'Ana');
Correct answer: INSERT INTO EMPLOYEES VALUES (101, 'Ana');
The correct Oracle syntax is INSERT INTO table_name [(columns)] VALUES (values).
Question 4: What is a column alias in SQL?
- A permanent rename of a column in the table
- A temporary label given to a column in the query result (Correct answer)
- An index on a column
- A constraint on a column
Correct answer: A temporary label given to a column in the query result
A column alias (using AS or a space) gives a temporary name to the column in the output without changing the underlying table.
Question 5: Which SQL function converts a string to uppercase?
- INITCAP
- LOWER
- UPPER (Correct answer)
- TRIM
Correct answer: UPPER
UPPER(string) returns the string with all characters converted to uppercase letters.
Question 6: What does SELECT * FROM employees WHERE salary IS NULL return?
- Rows where salary equals zero
- Rows where salary equals the string 'NULL'
- Rows where salary has no value stored (Correct answer)
- An error because NULL cannot be compared
Correct answer: Rows where salary has no value stored
IS NULL tests for the absence of a value; it returns rows where the salary column has no stored value.
Question 7: Which clause is required in every valid SELECT statement in Oracle?
- WHERE
- ORDER BY
- FROM (Correct answer)
- GROUP BY
Correct answer: FROM
Every SELECT statement requires a FROM clause to specify the data source (though DUAL can be used for expression-only queries).
In Oracle SQL, which pseudo-table is used when you want to SELECT an expression or function without referencing a real table?