Cheat sheet: Oracle Database SQL 1Z0-071 reference covering query syntax, joins, functions, subqueries, set operators, DML, DDL, and exam traps.
Independent quick reference for candidates preparing for Oracle Oracle Database SQL (1Z0-071). Use it to review high-yield syntax rules, common exam traps, and decision points for real Oracle SQL questions.
Use the tables for a quick pre-exam check. Expand a topic’s notes for explanations, examples, and additional distinctions.
Scope and study context
The exam rewards precision. Many missed questions are not caused by unfamiliar SQL, but by small details: NULL behavior, alias scope, join output, aggregate rules, datatype conversion, transaction control, and Oracle-specific syntax.
Single-row functions return one result per input row. They can be nested, used in SELECT, WHERE, and ORDER BY, and often appear in conversion or date questions.
Character functions
Function
Purpose
Example result idea
LOWER, UPPER, INITCAP
Change case
Useful for case-insensitive comparisons
CONCAT(a,b)
Concatenate two values
Similar to `a
SUBSTR(char, start, length)
Extract part of a string
Oracle positions are character-based
LENGTH(char)
Count characters
Spaces count
INSTR(char, search)
Find position
Returns position of search string
LPAD, RPAD
Pad to a length
Formatting output
TRIM
Remove leading/trailing characters
Default trims spaces
REPLACE
Replace matching text
Character substitution
Candidate trap: CONCAT takes two arguments, while || can chain multiple values.
Number functions
Function
Purpose
Trap
ROUND(number, n)
Round to n decimal places
Negative n rounds left of decimal
TRUNC(number, n)
Truncate to n decimal places
Does not round
MOD(m, n)
Remainder
Useful for divisibility checks
Date functions
Oracle DATE values include date and time components.
Function
Purpose
Review point
SYSDATE
Current database server date/time
Includes time
MONTHS_BETWEEN(d1, d2)
Months between dates
Can return fractional months
ADD_MONTHS(date, n)
Add months
Handles month boundaries
NEXT_DAY(date, char)
Next named weekday
Depends on date language settings
LAST_DAY(date)
Last day of month
High-yield date function
ROUND(date, fmt)
Round date to format unit
Format matters
TRUNC(date, fmt)
Truncate date to format unit
Common for removing time portion
EXTRACT(part FROM date)
Extract year, month, day, etc.
Syntax differs from normal functions
Conversion functions and format models
Function
Converts
Typical use
TO_CHAR(date, fmt)
Date to formatted text
Display dates
TO_CHAR(number, fmt)
Number to formatted text
Currency, decimal display
TO_DATE(char, fmt)
Text to date
Avoid implicit date conversion
TO_NUMBER(char, fmt)
Text to number
Controlled numeric conversion
High-yield format elements include YYYY, YY, RR, MM, MON, MONTH, DD, DAY, DY, HH, HH24, MI, SS, and numeric elements such as 9, 0, comma, decimal, and currency symbols.
Candidate trap: implicit conversion may work in one environment and fail in another because date and numeric formats can depend on session settings. For exam questions, explicit conversion with the correct format model is safer.
Every non-aggregate select expression must be grouped
SELECT department_id, job_id, AVG(salary) ... GROUP BY department_id, job_id
WHERE filters rows before grouping
Cannot use aggregate functions in WHERE
HAVING filters groups after grouping
Use HAVING AVG(salary) > 5000
Grouping by expression requires the expression
GROUP BY TRUNC(hire_date,'YEAR')
Nulls form a group
Null department values group together
-- Correct
SELECTdepartment_id,AVG(salary)FROMemployeesWHEREsalary>0GROUPBYdepartment_idHAVINGAVG(salary)>5000;-- Incorrect: aggregate in WHERE
SELECTdepartment_idFROMemployeesWHEREAVG(salary)>5000GROUPBYdepartment_id;
Joins
Join Type Selection
Need
Use
Notes
Matching rows in both tables
INNER JOIN
Default when JOIN without outer keyword
All rows from left table plus matches
LEFT OUTER JOIN
Unmatched right columns become null
All rows from right table plus matches
RIGHT OUTER JOIN
Less common; can often rewrite as left join
All rows from both sides
FULL OUTER JOIN
Unmatched columns become null
Join a table to itself
Self join
Requires aliases
Join on non-equality condition
Non-equijoin
Example: ranges
All combinations
Cross join
Cartesian product; often accidental
Join same-named columns automatically
NATURAL JOIN
Risky: uses all same-name columns
Join same-named selected columns
JOIN ... USING (col)
Cannot qualify col with table alias in select list
-- Preserves departments with no employees
SELECTd.department_name,e.last_nameFROMdepartmentsdLEFTOUTERJOINemployeeseONd.department_id=e.department_id;-- Trap: WHERE condition on right table can turn it into an effective inner join
SELECTd.department_name,e.last_nameFROMdepartmentsdLEFTOUTERJOINemployeeseONd.department_id=e.department_idWHEREe.job_id='SA_REP';-- Safer when the filter belongs to the matching condition
SELECTd.department_name,e.last_nameFROMdepartmentsdLEFTOUTERJOINemployeeseONd.department_id=e.department_idANDe.job_id='SA_REP';
USING and NATURAL JOIN Traps
-- With USING, do not qualify the joined column in the select list
SELECTdepartment_id,e.last_name,d.department_nameFROMemployeeseJOINdepartmentsdUSING(department_id);-- NATURAL JOIN joins on every column with the same name in both tables
SELECTemployee_id,department_nameFROMemployeesNATURALJOINdepartments;
Trap
Why it matters
Missing join condition
Produces Cartesian product
NATURAL JOIN
New same-name columns can silently change results
Qualifying a USING column
Invalid in common Oracle exam syntax
Filtering outer-joined table in WHERE
May remove null-extended rows
Join types
Join type
Purpose
Trap
Inner join
Rows with matching values
Nonmatching rows disappear
Left outer join
All rows from left table plus matches
Predicate placement can turn it into an inner join
Right outer join
All rows from right table plus matches
Same predicate trap
Full outer join
All matching and nonmatching rows from both sides
Nulls appear for missing side
Self-join
Table joined to itself
Requires aliases
Cross join
Cartesian product
Usually wrong unless intentional
Natural join
Joins same-name columns automatically
Dangerous if multiple same-name columns exist
ON, USING, and natural joins
Syntax
Best use
Watch for
JOIN ... ON t1.col = t2.col
Most explicit and safest
Qualify columns clearly
JOIN ... USING (col)
Same column name in both tables
The joined column is referenced once
NATURAL JOIN
Quick join on all same-name columns
Can silently join on unintended columns
For exam safety, prefer reasoning with ON because it makes the join condition explicit.
Outer join predicate trap
A common missed question places an outer join in the FROM clause but then filters the optional table in the WHERE clause.
Pattern
Effect
Left join plus WHERE right_table.status = 'A'
Often removes null-extended rows
Left join with condition in ON clause
Preserves left rows while limiting matches
WHERE right_table.col IS NULL after left join
Finds unmatched rows
When reading an outer join question, ask: “Is this condition part of the match, or is it filtering the final result?”
NOT EXISTS is often safer than NOT IN with nullable data
NOT IN and NULL
This is one of the highest-yield traps.
If a subquery used with NOT IN returns a NULL, the comparison can become unknown and return no rows that you expected. When nulls are possible, NOT EXISTS is often the safer logical pattern.
Correlated subquery reading method
For each row in the outer query:
Substitute the outer row’s relevant value into the inner query.
Evaluate the inner query.
Decide whether the outer row qualifies.
This mental model helps with questions using department averages, maximum salary by group, or existence checks.
Set Operators
Set Operator Matrix
Operator
Duplicates
Meaning
UNION
Removes duplicates
Rows from either query
UNION ALL
Keeps duplicates
Rows from either query, faster conceptually because no duplicate elimination
Similar effect to NOT NULL, but not the same declaration
UNIQUE with nulls
Null handling differs from ordinary equality intuition; do not treat null as a normal duplicate value
Views
A view is a stored query. It can simplify complex joins, restrict displayed columns, or present derived data.
View concept
Review point
Simple view
Often based on one table; may be updatable if rules are met
Complex view
Includes joins, groups, functions, or aggregates; update restrictions likely
WITH CHECK OPTION
Prevents changes through the view that violate the view condition
WITH READ ONLY
Prevents DML through the view
Candidate trap: a view does not automatically store a separate copy of ordinary query data like a table. It is generally a query definition unless materialized view concepts are explicitly involved.
Sequences
Sequences generate numeric values, commonly for surrogate keys.
Pseudocolumn
Meaning
sequence_name.NEXTVAL
Gets next sequence value
sequence_name.CURRVAL
Current value in session after NEXTVAL has been used
Case-sensitive for character data unless transformed
Range
BETWEEN low AND high
Inclusive on both ends
List match
IN (...)
Equivalent to multiple OR checks
Pattern match
LIKE
% means any length; _ means one character
Null test
IS NULL / IS NOT NULL
Never = NULL
Negative logic
NOT, <>, !=, NOT IN
NULL can change expected results
Combined logic
AND, OR
AND has higher precedence than OR
Notes and examples
Use parentheses when a condition mixes AND and OR. The exam often checks whether you know how a condition is actually evaluated.
NULL rules
NULL means unknown or unavailable, not zero, blank, or false.
Expression
Result concept
salary + NULL
NULL
commission_pct = NULL
Not true; use IS NULL
commission_pct <> NULL
Not true; use IS NOT NULL
NVL(commission_pct, 0)
Replace null with 0
COALESCE(a, b, c)
First non-null expression
NULLIF(a, b)
Returns NULL if a = b, else a
NVL2(expr, value_if_not_null, value_if_null)
Two-branch null handling
Sorting rules
Syntax
Meaning
ORDER BY col ASC
Ascending; often default
ORDER BY col DESC
Descending
ORDER BY 2
Sort by second select-list item
ORDER BY alias
Sort by select-list alias
NULLS FIRST / NULLS LAST
Explicit null placement
If a query does not include ORDER BY, do not assume output order.
Group functions and aggregation
Aggregate function essentials
Function
What it does
Null behavior
COUNT(*)
Counts rows
Includes rows with nulls
COUNT(expr)
Counts non-null expression values
Ignores nulls
COUNT(DISTINCT expr)
Counts distinct non-null values
Ignores nulls
SUM(expr)
Adds values
Ignores nulls
AVG(expr)
Averages values
Ignores nulls
MIN(expr)
Lowest value
Ignores nulls
MAX(expr)
Highest value
Ignores nulls
Notes and examples
Important difference:
AVG(commission_pct) averages only rows where commission_pct is not null.
AVG(NVL(commission_pct, 0)) treats null commission values as zero.
GROUP BY decision rule
If the SELECT list contains both aggregate expressions and non-aggregate expressions, every non-aggregate expression must be included in the GROUP BY.
Select-list item
Must be in GROUP BY?
department_id
Yes, if selected with aggregates
UPPER(job_id)
Yes, as the expression if selected with aggregates
COUNT(*)
No
AVG(salary)
No
Literal such as 'Total'
No
WHERE vs HAVING
Clause
Filters
Can use group functions?
WHERE
Rows before grouping
No
HAVING
Groups after grouping
Yes
Example decision:
Need employees with salary > 10000 before calculating department average? Use WHERE.
Need departments with AVG(salary) > 10000? Use HAVING.
DDL, data types, and constraints
Common Oracle data types
Data type
Use
Review point
VARCHAR2(size)
Variable-length character data
Common text type
CHAR(size)
Fixed-length character data
Pads to fixed length
NUMBER(p,s)
Numeric data
Precision and scale matter
DATE
Date and time to seconds
Not just date-only
TIMESTAMP
More precise date/time
Fractional seconds
CLOB
Large character data
Large text
BLOB
Binary large object
Binary data
Notes and examples
Constraint types
Constraint
Purpose
Key trap
NOT NULL
Column must have value
Column-level only in typical syntax
UNIQUE
Values must be unique
Multiple nulls may be allowed depending on columns
PRIMARY KEY
Unique row identifier
Implies uniqueness and not null
FOREIGN KEY
Enforces parent-child relationship
Child value must match parent or be null if allowed
CHECK
Enforces condition
Cannot rely on invalid expressions
DEFAULT
Supplies value when omitted
Not the same as inserting explicit NULL
Foreign key delete actions
Clause
Effect
No special clause
Parent delete blocked if child rows exist
ON DELETE CASCADE
Deletes dependent child rows
ON DELETE SET NULL
Sets child foreign key values to null
Data dictionary and metadata
Oracle data dictionary views are frequently grouped by prefix.
Prefix
Meaning
USER_
Objects owned by the current user
ALL_
Objects accessible to the current user
DBA_
Database-wide administrative views, if privileged
Examples you may see conceptually include table, column, constraint, view, sequence, index, and synonym metadata. Know the difference between owning an object and merely having access to it.
Privileges and security basics
Privilege types
Type
Examples
Granted on
System privilege
CREATE SESSION, CREATE TABLE
Capability in the database
Object privilege
SELECT, INSERT, UPDATE, DELETE
Specific object
Role
Named collection of privileges
Granted to users or other roles depending on rules
Grant option distinctions
Clause
Applies to
Meaning
WITH GRANT OPTION
Object privileges
Recipient can grant that object privilege to others
WITH ADMIN OPTION
System privileges or roles
Recipient can administer/grant it further
Candidate trap: revoking a privilege can have cascading effects for object privileges granted onward through WITH GRANT OPTION.
Common 1Z0-071 mistake checklist
Before answering, check these items:
Is there an ORDER BY? If not, do not assume row order.
Is NULL involved? Replace normal comparison thinking with three-valued logic.
Is an alias used too early?WHERE cannot see select-list aliases.
Are aggregate and non-aggregate columns mixed? Check GROUP BY.
Is the filter row-level or group-level? Choose WHERE vs HAVING.
Is the join natural? Look for unintended same-name columns.
Is an outer join filtered in WHERE? It may remove null-extended rows.
Can a subquery return multiple rows? Use the right operator.
Can a NOT IN subquery return null? Consider the null trap.
Do set operator queries align? Same column count and compatible datatype groups.
Is a date literal or conversion format ambiguous? Prefer explicit conversion.
Is the statement DML or DDL? Transaction behavior differs.
Does a synonym exist? That does not mean the user has privileges.
Is a sequence expected to be gap-free? Do not assume that.
Is COUNT(*) being confused with COUNT(column)? Null handling differs.
Fast decision tables
Which clause should solve the problem?
Requirement
Likely clause
Choose displayed columns or expressions
SELECT
Choose source tables
FROM
Connect tables
JOIN ... ON or USING
Filter rows before grouping
WHERE
Group rows
GROUP BY
Filter groups
HAVING
Sort final output
ORDER BY
Notes and examples
Which SQL feature should solve the problem?
Requirement
Feature
Replace null commission with zero
NVL or COALESCE
Display date as text
TO_CHAR
Convert text to date
TO_DATE
Compare to department average
Subquery or analytic logic if provided
Return departments with no employees
Outer join plus null check or NOT EXISTS
Combine two result sets and remove duplicates
UNION
Combine two result sets and keep duplicates
UNION ALL
Find rows in first query but not second
MINUS
Generate new numeric key values
Sequence
Prevent invalid child rows
Foreign key constraint
Restrict DML through a view
WITH CHECK OPTION or WITH READ ONLY
Practice plan after this review
Use this page as a final concept pass, then move into active recall:
Topic drills: Work in focused sets: joins, subqueries, group functions, DML, DDL, and set operators.
Original practice questions: Prioritize questions that require predicting output or identifying invalid SQL.
Detailed explanations: For every missed item, identify the exact rule: alias scope, null behavior, datatype conversion, grouping rule, transaction behavior, or privilege rule.
Mixed question bank sessions: After topic drills, use mixed sets to practice switching between concepts under time pressure.
Mock exams: Use full-length practice only after your weak topics are improving; otherwise, mock exams mostly confirm the same gaps.
Final quick review routine
In your last study block before more practice, review in this order:
NULL rules and conditional functions.
Group functions, GROUP BY, and HAVING.
Join types and outer join predicate placement.
Subquery operators, especially IN, ANY, ALL, EXISTS, and NOT IN.
Set operator alignment rules.
DML vs DDL transaction behavior.
Constraints, views, sequences, synonyms, and privileges.
Next step: move from reading to doing—start a focused 1Z0-071 question bank session with topic drills and detailed explanations, then use your missed questions to drive the next review pass.