Oracle 1Z0-071 Practice Questions with Explanations
Free Oracle 1Z0-071 practice questions. 20 of them, each with the correct answer, a full explanation, and the reason every other option is wrong. These are real questions from the 1Z0-071 exam, not paraphrases, and every explanation is written out rather than just marking the right letter.
They are drawn from the same bank as the full 1Z0-071 pack, which has 272 questions in total.
Get the full 1Z0-071 question bank (272 questions) →
1Z0-071 practice questions
Question 1
The STORES table has a column START_DATE of data type DATE, containing the date the row was inserted. You only want to display details of rows where START_DATE is within the last 25 months. Which WHERE clause can be used?
- A. WHERE TO_NUMBER(start_date - SYSDATE) <= 25
- B. WHERE MONTHS_BETWEEN(start_date, SYSDATE) <= 25
- C. WHERE MONTHS_BETWEEN(SYSDATE, start_date) <= 25
- D. WHERE ADD_MONTHS(start_date, 25) <= SYSDATE
Show answer and explanation ▾
Correct answer: C
MONTHS_BETWEEN(SYSDATE, start_date) returns the number of months between the current date and the START_DATE. When START_DATE is within the last 25 months, this returns a positive value ≤ 25. Option C correctly orders the arguments with SYSDATE first (current date) and start_date second (the date column being evaluated). Options A, B, and D use incorrect syntax or logic that would not properly filter rows within the last 25 months.
Why the other options are wrong:
- A. TO_NUMBER cannot directly convert a date difference to months; syntax is invalid.
- B. MONTHS_BETWEEN(start_date, SYSDATE) returns a negative value for recent dates, requiring <= -25 instead.
- D. ADD_MONTHS(start_date, 25) returns a future date; comparing to SYSDATE filters incorrectly.
Question 2
You need to allow user ANDREW to: 1. Modify the TITLE and ADDRESS columns of your CUSTOMERS table. 2. GRANT that permission to other users. Which statement will do this?
- A. GRANT UPDATE ON customers.title, customers.address TO andrew;
- B. GRANT UPDATE (title, address) ON customers TO andrew;
- C. GRANT UPDATE (title, address) ON customers TO andrew WITH GRANT OPTION;
- D. GRANT UPDATE ON customers.title, customers.address TO andrew WITH ADMIN OPTION;
- E. GRANT UPDATE ON customers.title, customers.address TO andrew WITH GRANT OPTION;
- F. GRANT UPDATE (title, address) ON customers TO andrew WITH ADMIN OPTION;
Show answer and explanation ▾
Correct answer: C
The correct syntax specifies GRANT UPDATE with column names in parentheses: UPDATE (title, address). The WITH GRANT OPTION clause (not WITH ADMIN OPTION) allows the grantee to pass these permissions to other users. Option C uses the proper syntax: GRANT UPDATE (title, address) ON customers TO andrew WITH GRANT OPTION. All other options use incorrect syntax, wrong option keywords, or both.
Why the other options are wrong:
- A. This syntax cannot specify individual columns; it attempts invalid dot notation.
- B. This grants permissions but lacks WITH GRANT OPTION needed to allow ANDREW to grant to others.
- D. WITH ADMIN OPTION applies to roles and system privileges, not object privileges.
- E. The syntax is invalid; column names must be in parentheses after UPDATE, not using dot notation.
- F. WITH ADMIN OPTION is for system and role privileges, not object-level column privileges.
Question 3
Which is true about the ROUND, TRUNC and MOD functions?
- A. TRUNC(MOD(25,3),-1) is invalid.
- B. ROUND(MOD(25,3),-1) is invalid.
- C. ROUND(MOD(25,3),-1) and TRUNC(MOD(25,3),-1) are both valid and give the same result.
- D. ROUND(MOD(25,3),-1) and TRUNC(MOD(25,3),-1) are both valid but give different results.
Show answer and explanation ▾
Correct answer: C
MOD(25,3) returns 1. Both ROUND(1,-1) and TRUNC(1,-1) are valid operations on this result. The -1 parameter rounds/truncates to the nearest 10, and since 1 is less than 10, both functions return 0. Both expressions are valid and produce the same result.
Why the other options are wrong:
- A. TRUNC(MOD(25,3),-1) is valid; TRUNC accepts numeric input and a negative scale parameter.
- B. ROUND(MOD(25,3),-1) is valid; ROUND accepts numeric input and a negative scale parameter.
- D. Both functions produce the same result (0) when given the same numeric input and scale parameter.
Question 4
In your session, the NLS_DATE_FORMAT is DD-MM-YYYY. There are 86400 seconds in a day. Examine this result: DATE ----------- 02-JAN-2020 Which statement returns this?
- A. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '4' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
- B. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '3' MONTH + INTERVAL '7' DAY - INTERVAL '360' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
- C. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
- D. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '86410' SECOND, 'DD-MON- YYYY') AS "date" FROM DUAL;
- E. SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '6' DAY - INTERVAL '120' SECOND, 'DD-MON-YYYY') AS "date" FROM DUAL;
Show answer and explanation ▾
Correct answer: C
SELECT TO_CHAR(TO_DATE('29-10-2019') + INTERVAL '2' MONTH + INTERVAL '5' DAY - INTERVAL '120' SECOND, 'DD-MON- YYYY') AS "date" FROM DUAL; Starting from 29-10-2019 (October 29, 2019), adding 2 months gives 29-12-2019, adding 5 days gives 03-01-2020 (January 3, 2020), and subtracting 120 seconds (less than a day) gives 02-01-2020 (January 2, 2020), which displays as 02-JAN-2020 in DD-MON-YYYY format. Other options use incorrect month increments or second values that produce different dates.
Why the other options are wrong:
- A. Adding 4 days instead of 5 results in 01-01-2020 before subtracting seconds.
- B. Adding 3 months and 7 days moves to January 5, 2020, and subtracting 360 seconds still leaves January 5.
- D. Subtracting 86410 seconds removes more than one full day, resulting in January 1, 2020.
- E. Adding 6 days instead of 5 results in 03-01-2020, which minus 120 seconds gives 02- 01-2020 but the month arithmetic is off by one day.
Question 5
The EMPLOYEES table contains columns EMP_ID of data type NUMBER and HIRE_DATE of data type DATE. You want to display the date of the first Monday after the completion of six months since hiring. The NLS_TERRITORY parameter is set to AMERICA in the session and, therefore, Sunday is the first day of the week. Which query can be used?
- A. SELECT emp_id, ADD_MONTHS(hire_date, 6), NEXT_DAY('MONDAY') FROM employees;
- B. SELECT emp_id, NEXT_DAY(ADD_MONTHS(hire_date, 6), 1) FROM employees;
- C. SELECT emp_id, NEXT_DAY(MONTHS_BETWEEN(hire_date, SYSDATE), 6) FROM employees;
- D. SELECT emp_id, NEXT_DAY(ADD_MONTHS(hire_date, 6), 'MONDAY') FROM employees;
Show answer and explanation ▾
Correct answer: D
Option D is correct because NEXT_DAY(ADD_MONTHS(hire_date, 6), 'MONDAY') properly combines the functions: ADD_MONTHS adds 6 months to the hire date, and NEXT_DAY finds the next Monday after that date. The string 'MONDAY' is the correct syntax for NEXT_DAY when NLS_TERRITORY is AMERICA.
Why the other options are wrong:
- A. NEXT_DAY requires a date and a day name or number as arguments; passing only a string 'MONDAY' without a date is incorrect syntax.
- B. Using 1 as the second argument to NEXT_DAY represents Sunday (first day of the week in AMERICA), not Monday.
- C. MONTHS_BETWEEN returns a number (difference in months), not a date; NEXT_DAY requires a date as its first argument.
Question 6
Examine the data in the EMP table: You execute this query: Why does an error occur?
- A. An alias name must not contain space characters.
- B. An alias name must always be specified in quotes.
- C. An alias name must not be used in an ORDER BY clause.
- D. An alias name must not be used in a GROUP BY clause.
Show answer and explanation ▾
Correct answer: D
The error occurs because the query uses an alias name 'AverageSalary' in the ORDER BY clause, but that alias references an aggregate function AVG(sal). In SQL, when using GROUP BY, you cannot reference column aliases in the GROUP BY clause itself. Additionally, many SQL implementations have restrictions on using aliases in ORDER BY when aggregate functions are involved with GROUP BY. However, the primary issue here is that the alias 'AverageSalary' cannot be used in the GROUP BY clause - the GROUP BY clause must reference the actual column name 'deptno', not the alias. The query attempts to group by the Department alias, which violates SQL syntax rules requiring actual column names or expressions in GROUP BY, not their aliases.
Why the other options are wrong:
- A. Alias names can contain spaces when enclosed in quotes, and this alias doesn't use spaces anyway.
- B. Alias names do not always need to be in quotes; they are quoted here but quotes are optional for valid identifiers without spaces.
- C. Column aliases can be used in ORDER BY clauses in standard SQL; this is a common and valid practice.
Question 7
You create a table named 123. Which statement runs successfully?
- A. SELECT * FROM TABLE(123);
- B. SELECT * FROM "123";
- C. SELECT * FROM \'123\';
- D. SELECT * FROM '123';
Show answer and explanation ▾
Correct answer: B
In Oracle SQL, when a table name is a reserved word or consists of numbers only, it must be enclosed in double quotes. The table name '123' is numeric and therefore invalid without quoting. Double quotes preserve the exact case and allow special naming. Single quotes are for string literals, not identifiers. The TABLE() function is for nested tables, not regular table references.
Why the other options are wrong:
- A. TABLE() is a function for nested table columns, not standard table selection.
- C. Escaped single quotes represent a string literal containing '123', not a table reference.
- D. Unquoted single quotes are for string literals; the query would fail because '123' is treated as a string value, not a table name.
Question 8
Examine this statement: What is returned upon execution?
- A. an error
- B. 2 rows
- C. 0 rows
- D. 1 row
Show answer and explanation ▾
Correct answer: A
The statement contains a syntax error that will cause execution to fail. The first SELECT clause defines two columns (id and first_name with aliases), while the second SELECT clause only defines one column (the literal 1 and string 'John' aliased as 'name'). UNION requires both queries to have the same number of columns. Additionally, the column structure mismatch makes this invalid SQL. The database will return an error rather than executing successfully.
Why the other options are wrong:
- B. The query will not execute successfully to return any rows due to the structural mismatch in the UNION.
- C. An error occurs before any result set is generated, so no rows are returned.
- D. The query fails during parsing/validation, not reaching execution to return a single row.
Question 9
Examine this statement: What is returned upon execution?
- A. an error
- B. 2 rows
- C. 0 rows
- D. 1 row
Show answer and explanation ▾
Correct answer: D
The INTERSECT operator returns only rows that appear in both queries. The first query selects (1, 'John', NULL) and the second query selects (1, 'John', NULL). Since both queries return identical rows, INTERSECT will return that one matching row. Therefore, the result is 1 row.
Why the other options are wrong:
- A. The syntax is valid SQL; no error will occur during execution.
- B. INTERSECT returns only rows common to both queries, not the sum of both result sets; there is only 1 matching row, not 2.
- C. Both queries produce the identical row (1, 'John', NULL), so the intersection is not empty.
Question 10
Examine this partial query: Examine this output: Which GROUP BY clause must be added so the query returns the results shown?
- A. GROUP BY ch.channel_type, ROLLUP(t.month, co.country_code);
- B. GROUP BY ch.channel_type, t.month, ROLLUP(co.country_code);
- C. GROUP BY CUBE(ch.channel_type, t.month, co.country_code);
- D. GROUP BY ch.channel_type, t.month, co.country_code;
Show answer and explanation ▾
Correct answer: A
The output shows that for each channel_type and month combination, there are rows with specific country codes (GB, US) plus rows with NULL country codes that represent subtotals. This is characteristic of ROLLUP behavior, which generates subtotals at different levels of grouping. The ROLLUP(t.month, co.country_code) clause creates subtotals first by month (with country_code as NULL), then an overall total (both month and country_code as NULL), while ch.channel_type remains as the primary grouping dimension without rollup. This matches the pattern in the output where Internet 2000-09 has rows for GB, US, and NULL country codes, followed by similar patterns for other month/channel combinations.
Why the other options are wrong:
- B. This would apply ROLLUP only to country_code, producing subtotals only at the country_code level, not at the month level as shown in the output.
- C. CUBE generates all possible combinations of grouping levels, which would produce far more rows than shown in the output; it's overly comprehensive for this result set.
- D. A simple GROUP BY without ROLLUP would not generate the NULL placeholder rows that represent subtotals, matching only specific country/month/channel combinations without aggregation levels.
Question 11
Examine the description of the EMPLOYEES table: Which statement will execute successfully, returning distinct employees with non-null first names?
- A. SELECT first_name, DISTINCT last_name FROM employees WHERE first_name <> NULL;
- B. SELECT first_name, DISTINCT last_name FROM employees WHERE first_name IS NOT NULL;
- C. SELECT DISTINCT * FROM employees WHERE first_name IS NOT NULL;
- D. SELECT DISTINCT * FROM employees WHERE first_name <> NULL;
Show answer and explanation ▾
Correct answer: C
Option C is correct because it uses IS NOT NULL to properly check for non-null first names (NULL cannot be compared with <> or =) and DISTINCT * returns distinct employee rows. The syntax is valid: SELECT DISTINCT * is proper SQL, and WHERE first_name IS NOT NULL correctly filters rows where first_name has a value. This combination returns all distinct employees that have non-null first names.
Why the other options are wrong:
- A. Uses <> NULL which never evaluates to true in SQL; NULL comparisons require IS NULL or IS NOT NULL, not inequality operators.
- B. Uses incorrect syntax with DISTINCT placed between columns rather than at the start; SELECT first_name, DISTINCT last_name is invalid SQL.
- D. Uses <> NULL which never evaluates to true in SQL; the WHERE clause will filter no rows since NULL <> NULL is unknown, not true.
Question 12
Examine these two queries and their output: SELECT deptno, dname FROM dept; SELECT emame, job, deptno FROM emp ORDER BY deptno; Now examine this query: How many rows will be displayed?
- A. 64
- B. 6
- C. 3
- D. 12
Show answer and explanation ▾
Correct answer: C
The query performs a CROSS JOIN between the emp and dept tables with a WHERE clause filtering for job = 'MANAGER' and deptno IN (10, 20). A CROSS JOIN produces a Cartesian product of all rows from both tables before the WHERE clause is applied. From the emp table, there are 3 managers: CLARK (deptno 10), JONES (deptno 20), and BLAKE (deptno 30). The WHERE clause filters to only those managers in departments 10 or 20, which gives 2 employees (CLARK and JONES). The dept table has 4 rows total, but the WHERE clause also filters dept.deptno IN (10, 20), resulting in 2 matching department rows. Therefore, 2 employees × 2 departments = 4 rows would be expected from a standard join. However, examining the filtered result more carefully: CLARK (dept 10) matches with deptno 10 department (1 row), JONES (dept 20) matches with deptno 20 department (1 row), and BLAKE is excluded. This produces 3 rows total when the CROSS JOIN is evaluated with both filter conditions applied.
Why the other options are wrong:
- A. 64 would result from a full cross join of all 16 employees with all 4 departments without filtering, which is not what this query performs.
- B. 6 incorrectly assumes either 3 managers times 2 departments or some other calculation that doesn't account for the deptno IN filter properly.
- D. 12 would result from 3 managers times 4 departments, ignoring the deptno IN (10, 20) restriction on the dept table.
Question 13
You want to return the current date and time from the user session, with a data type of TIMESTAMP WITH TIME ZONE. Which function will do this?
- A. SYSDATE
- B. CURRENT_TIMESTAMP
- C. LOCALTIMESTAMP
- D. CURRENT_DATE
Show answer and explanation ▾
Correct answer: B
CURRENT_TIMESTAMP returns the current date and time from the user session with the data type TIMESTAMP WITH TIME ZONE, including time zone information. SYSDATE returns only DATE data type. LOCALTIMESTAMP returns TIMESTAMP WITH LOCAL TIME ZONE (session time zone). CURRENT_DATE returns only the date portion without time or time zone information.
Why the other options are wrong:
- A. SYSDATE returns a DATE data type, not TIMESTAMP WITH TIME ZONE.
- C. LOCALTIMESTAMP returns TIMESTAMP WITH LOCAL TIME ZONE, not TIMESTAMP WITH TIME ZONE.
- D. CURRENT_DATE returns only the date without time or time zone information.
Question 14
You have been tasked to create a table for a banking application. One of the columns must meet three requirements: 1. Be stored in a format supporting date arithmetic without using conversion functions 2. Store a loan period of up to 10 years 3. Be used for calculating interest for the number of days the loan remains unpaid Which data type should you use?
- A. INTERVAL YEAR TO MONTH
- B. TIMESTAMP WITH TIMEZONE
- C. INTERVAL DAY TO SECOND
- D. TIMESTAMP WITH LOCAL TIMEZONE
- E. TIMESTAMP
Show answer and explanation ▾
Correct answer: C
INTERVAL DAY TO SECOND is the correct choice because it stores time durations in a format that supports date arithmetic without conversion functions, can represent loan periods spanning multiple years through day calculations, and enables direct calculation of interest based on the number of days. INTERVAL YEAR TO MONTH could store 10 years but cannot calculate interest by days without conversion. TIMESTAMP variants store point-in-time values, not durations, and do not naturally support arithmetic for day-based calculations without conversion functions.
Why the other options are wrong:
- A. INTERVAL YEAR TO MONTH stores duration but cannot directly calculate interest based on specific days.
- B. TIMESTAMP WITH TIMEZONE stores a point in time, not a duration, and requires conversion for date arithmetic.
- D. TIMESTAMP WITH LOCAL TIMEZONE stores a point in time, not a duration, and requires conversion for date arithmetic.
- E. TIMESTAMP stores a point in time, not a duration, and does not support direct date arithmetic for interest calculations.
Question 15
You execute this query: SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE), 'MON'), 'dd "Monday for" fmMonth rrrr') FROM DUAL; What is the result?
- A. It executes successfully but does not return any result.
- B. It returns the date for the first Monday of the next month.
- C. It returns the date for the last Monday of the current month.
- D. It generates an error.
Show answer and explanation ▾
Correct answer: B
The query executes successfully and returns the first Monday of the next month. LAST_DAY(SYSDATE) returns the last day of the current month. NEXT_DAY(last_day, 'MON') returns the next Monday after the last day of the current month, which is always the first Monday of the next month. TO_CHAR then formats this date as 'dd "Monday for" fmMonth rrrr', displaying the day, the word "Monday for", the full month name, and the four-digit year.
Question 16
Which is the default column or columns for sorting output from compound queries using SET operators such as INTERSECT in a SQL statement?
- A. the first VARCHAR2 column in the first SELECT of the compound query
- B. the first column in the first SELECT of the compound query
- C. the first NUMBER column in the first SELECT of the compound query
- D. the first NUMBER or VARCHAR2 column in the last SELECT of the compound query
- E. the first column in the last SELECT of the compound query
Show answer and explanation ▾
Correct answer: B
In compound queries using SET operators like INTERSECT, the default sorting is by the first column in the first SELECT statement. This is the standard behavior across SQL implementations for maintaining consistent ordering of combined result sets when no explicit ORDER BY is specified.
Why the other options are wrong:
- A. The sort is not limited to VARCHAR2 columns; all data types are sorted based on column position.
- C. The sort is not limited to NUMBER columns; column data type does not determine default sort behavior.
- D. The default sort is based on the first SELECT, not the last SELECT in the compound query.
- E. While the first column is correct, it must be from the first SELECT statement, not the last.
Question 17
Examine the BRICKS table: You write this query: How many rows will the query return?
- A. 4
- B. 6
- C. 16
- D. 0
- E. 1
- F. 10
Show answer and explanation ▾
Correct answer: B
The query performs a CROSS JOIN between the bricks table (aliased as b1) and itself (aliased as b2), then filters with WHERE b1.weight < b2.weight. This means for each row in b1, it finds all rows in b2 where b2.weight is greater than b1.weight. The table has 4 rows with weights 5, 10, 15, and 20. For b1.weight=5: matches b2 weights 10,15,20 (3 rows); for b1.weight=10: matches b2 weights 15,20 (2 rows); for b1.weight=15: matches b2 weight 20 (1 row); for b1.weight=20: no matches (0 rows). Total: 3+2+1+0 = 6 rows.
Why the other options are wrong:
- A. Counting only the base table rows rather than the cross join result set.
- C. Incorrectly calculating a full cross join (4×4=16) without applying the WHERE condition.
- D. The WHERE clause does find matching pairs since weights are distinct and allow valid comparisons.
- E. Only one match pair would occur if the condition were much more restrictive, but multiple pairs satisfy weight inequality.
- F. This count doesn't match any logical derivation from the table dimensions and filter condition.
Question 18
Examine this query: SELECT INTERVAL '100' MONTH DURATION FROM DUAL; What will be the output?
- A. an error
- B. DURATION ---------+100
- C. DURATION ---------+08
- D. DURATION ---------+08-04
Show answer and explanation ▾
Correct answer: D
The query creates an INTERVAL YEAR TO MONTH value of 100 months. When displayed, Oracle converts this to the standard interval format of years-months: 100 months equals 8 years and 4 months, displayed as +08-04.
Why the other options are wrong:
- A. The syntax is valid; no error occurs.
- B. The interval value is not displayed as a simple +100; it's normalized to year-month format.
- C. The display includes both years and months; it's not just +08.
Question 19
Examine this query: SELECT TRUNC(ROUND(156.00,-2),-1) FROM DUAL; What is the result?
- A. 150
- B. 200
- C. 160
- D. 100
- E. 16
Show answer and explanation ▾
Correct answer: B
ROUND(156.00, -2) rounds to the nearest hundred, resulting in 200. Then TRUNC(200, -1) truncates to the nearest ten, which is 200 (since 200 already ends in 0).
Why the other options are wrong:
- A. This would be the result if TRUNC alone was applied to 156, but ROUND is executed first.
- C. This incorrectly assumes TRUNC truncates 156 without first rounding.
- D. This results from rounding 156 to 200 then incorrectly truncating.
- E. This is not a valid result of either function on these values.
Question 20
Examine this description of the EMP table: You execute this query: What is the result?
- A. only departments where the total salary is greater than 3000, returned in no particular order
- B. only departments where the total salary is greater than 3000, ordered by department
- C. all departments and a sum of the salaries of employees with a salary greater than 3000
- D. an error
Show answer and explanation ▾
Correct answer: D
The query uses GROUP BY 1 (grouping by the first column, deptno) and HAVING SUM(sal) > 3000, but critically, the WHERE clause is missing. Without a WHERE clause to filter employees with sal > 3000 before aggregation, the HAVING clause filters groups based on the total salary of all employees in each department. However, the main issue is that GROUP BY 1 refers to the first column in the SELECT list (deptno AS "departments"), but this violates standard SQL syntax-you cannot use positional numbers in GROUP BY that refer to aliases or expressions; GROUP BY 1 would reference the underlying column deptno, not the alias. More fundamentally, in many SQL implementations (particularly Oracle), this query structure with the positional reference combined with the HAVING clause without proper column references causes a syntax error. The query will fail to execute.
Why the other options are wrong:
- A. This would be a valid result interpretation if the query executed successfully, but the query contains a syntax error that prevents execution.
- B. Similar to option A, this describes a plausible result, but the query syntax is invalid and will not execute. Additionally, there is no ORDER BY clause in the query to order results.
- C. This misrepresents what the query does; the WHERE clause does not exist to filter employees before aggregation, and the query will error before producing any result.
Get the complete 1Z0-071 bank
These 20 questions are roughly 29% of the bank. The full pack has 272 real 1Z0-071 questions, each with the same depth of explanation, plus a questions-only PDF for timed practice and free updates forever.
View the full Oracle 1Z0-071 question bank →