1Z0-071 — Oracle Database SQL Quick Reference

Compact 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.

Core SELECT Processing

Logical Query Order vs Written Order

Written clause orderLogical evaluation ideaExam points
SELECT5Column expressions, aliases, aggregate output
FROM1Tables, views, joins, inline views
WHERE2Row filtering before grouping
GROUP BY3Creates groups for aggregate evaluation
HAVING4Group filtering after aggregation
ORDER BY6Final sort; can use select-list aliases
Row limiting7Applied after ordering when used correctly
SELECT department_id, AVG(salary) AS avg_sal
FROM employees
WHERE salary IS NOT NULL
GROUP BY department_id
HAVING AVG(salary) > 5000
ORDER BY avg_sal DESC;

Alias Rules

LocationCan use select-list alias?Notes
ORDER BYYesCommon exam-safe use
WHERENoWHERE is evaluated before SELECT alias creation
GROUP BYUsually avoidUse the original expression for exam-style Oracle SQL
HAVINGUsually avoidUse the aggregate expression
Same select listNoAn alias is not normally reusable by another expression in the same select list
-- Correct
SELECT salary * 12 AS annual_salary
FROM employees
ORDER BY annual_salary;

-- Avoid / exam trap
SELECT salary * 12 AS annual_salary
FROM employees
WHERE annual_salary > 100000;

Filtering, Sorting, and Operators

Comparison and Null Logic

PredicateMeaningTrap
=, <>, !=, <, >, <=, >=Standard comparisonsComparisons with NULL return unknown, not true
BETWEEN a AND bInclusive rangeEquivalent to >= a AND <= b
IN (...)Matches any listed valueIN with NULL does not match null rows
LIKEPattern matching% = any length, _ = one character
IS NULLTests nullUse instead of = NULL
IS NOT NULLTests non-nullUse instead of <> NULL
ANDBoth conditionsEvaluated before OR
OREither conditionUse parentheses to control intent
NOTNegates conditionWatch NOT IN with nulls
SELECT last_name
FROM employees
WHERE commission_pct IS NULL;

SELECT last_name
FROM employees
WHERE last_name LIKE 'Smi_h%' ESCAPE '\';

Boolean Precedence

Higher to lowerExample
Comparisons and pattern testssalary > 5000, job_id LIKE 'SA%'
NOTNOT department_id = 10
ANDa AND b
ORa OR b

Exam trap:

-- Means: department_id = 10 OR (department_id = 20 AND salary > 5000)
WHERE department_id = 10 OR department_id = 20 AND salary > 5000

-- Clearer:
WHERE (department_id = 10 OR department_id = 20)
  AND salary > 5000

Sorting Rules

SyntaxResult
ORDER BY col ASCAscending; default
ORDER BY col DESCDescending
ORDER BY 2Sort by second select-list expression
ORDER BY aliasSort by select-list alias
NULLS FIRST / NULLS LASTExplicit null placement
SELECT employee_id, last_name, salary * 12 AS annual_pay
FROM employees
ORDER BY annual_pay DESC NULLS LAST;

Single-Row Functions

Character Functions

FunctionPurposeExample result idea
LOWER(char)LowercaseLOWER('SQL')sql
UPPER(char)UppercaseUPPER('sql')SQL
INITCAP(char)Initial capitalsINITCAP('oracle sql')
CONCAT(a,b)Concatenate two valuesOnly two arguments
`ab`
SUBSTR(char,start,len)SubstringPositions start at 1
LENGTH(char)Character lengthCounts characters
INSTR(char,search)Position of substring0 if not found
LPAD / RPADPad left/rightFormatting output
TRIMRemove leading/trailing charsSpaces by default
REPLACEReplace substringCase-sensitive
SELECT UPPER(last_name),
       SUBSTR(phone_number, 1, 3),
       first_name || ' ' || last_name AS full_name
FROM employees;

Number Functions

FunctionPurposeKey distinction
ROUND(n, d)Rounds to d decimalsMay increase value
TRUNC(n, d)Truncates to d decimalsDoes not round
MOD(n, m)RemainderUseful for divisibility
SELECT ROUND(45.926, 2), TRUNC(45.926, 2), MOD(10, 3)
FROM dual;

Date Functions and Date Arithmetic

ExpressionMeaningExam point
SYSDATECurrent database server date/timeIncludes time component
CURRENT_DATECurrent date in session time zoneDifferent from SYSDATE in some environments
date + nAdd n daysn may be fractional
date - nSubtract n days
date1 - date2Difference in daysNumeric result
MONTHS_BETWEEN(d1,d2)Months between datesMay return fractional months
ADD_MONTHS(d,n)Add monthsHandles month boundaries
NEXT_DAY(d,'MONDAY')Next named weekdayLanguage-sensitive
LAST_DAY(d)Last day of month
ROUND(date,'MONTH')Round dateDate granularity
TRUNC(date,'YEAR')Truncate dateCommon for grouping
SELECT hire_date,
       hire_date + 7 AS one_week_later,
       MONTHS_BETWEEN(SYSDATE, hire_date) AS months_employed
FROM employees;

Conversion and Conditional Expressions

Conversion Functions

FunctionPurposeExample
TO_CHAR(date, fmt)Date to textTO_CHAR(hire_date,'YYYY-MM-DD')
TO_CHAR(number, fmt)Number to textTO_CHAR(salary,'999,999')
TO_DATE(char, fmt)Text to dateTO_DATE('2026-06-18','YYYY-MM-DD')
TO_NUMBER(char, fmt)Text to numberTO_NUMBER('1,200','9,999')

Common format model elements:

ElementMeaning
YYYYFour-digit year
YYTwo-digit year
RRTwo-digit year with Oracle RR century logic
MMMonth number
MONAbbreviated month name
MONTHFull month name
DDDay of month
DYAbbreviated day name
DAYFull day name
HH24Hour 0-23
MIMinute
SSSecond
AM / PMMeridian indicator
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')
FROM dual;

Null and Conditional Functions

FunctionReturnsHigh-yield distinction
NVL(expr1, expr2)expr2 if expr1 is nullOracle-specific; data types must be compatible
NVL2(expr1, expr2, expr3)expr2 if not null, else expr3Reverses common intuition
NULLIF(expr1, expr2)NULL if equal, else expr1Useful to avoid divide-by-zero logic
COALESCE(a,b,c,...)First non-null expressionANSI-style; multiple expressions
CASEConditional resultSearched or simple form
DECODEOracle conditional comparisonOlder Oracle-specific style
SELECT last_name,
       NVL(commission_pct, 0) AS commission_pct,
       CASE
         WHEN salary >= 10000 THEN 'HIGH'
         WHEN salary >= 5000  THEN 'MID'
         ELSE 'LOW'
       END AS salary_band
FROM employees;

Aggregate Functions and Grouping

Aggregate Function Behavior

FunctionCounts nulls?Notes
COUNT(*)YesCounts rows
COUNT(expr)NoCounts non-null expression values
COUNT(DISTINCT expr)NoCounts distinct non-null values
SUM(expr)NoNumeric/date interval-style use depends on expression
AVG(expr)NoNulls excluded from denominator
MIN(expr)NoWorks on comparable data
MAX(expr)NoWorks on comparable data
SELECT department_id,
       COUNT(*) AS row_count,
       COUNT(commission_pct) AS commission_count,
       AVG(salary) AS avg_salary
FROM employees
GROUP BY department_id;

GROUP BY Rules

RuleExample / trap
Every non-aggregate select expression must be groupedSELECT department_id, job_id, AVG(salary) ... GROUP BY department_id, job_id
WHERE filters rows before groupingCannot use aggregate functions in WHERE
HAVING filters groups after groupingUse HAVING AVG(salary) > 5000
Grouping by expression requires the expressionGROUP BY TRUNC(hire_date,'YEAR')
Nulls form a groupNull department values group together
-- Correct
SELECT department_id, AVG(salary)
FROM employees
WHERE salary > 0
GROUP BY department_id
HAVING AVG(salary) > 5000;

-- Incorrect: aggregate in WHERE
SELECT department_id
FROM employees
WHERE AVG(salary) > 5000
GROUP BY department_id;

Joins

Join Type Selection

NeedUseNotes
Matching rows in both tablesINNER JOINDefault when JOIN without outer keyword
All rows from left table plus matchesLEFT OUTER JOINUnmatched right columns become null
All rows from right table plus matchesRIGHT OUTER JOINLess common; can often rewrite as left join
All rows from both sidesFULL OUTER JOINUnmatched columns become null
Join a table to itselfSelf joinRequires aliases
Join on non-equality conditionNon-equijoinExample: ranges
All combinationsCross joinCartesian product; often accidental
Join same-named columns automaticallyNATURAL JOINRisky: uses all same-name columns
Join same-named selected columnsJOIN ... USING (col)Cannot qualify col with table alias in select list
SELECT e.last_name, d.department_name
FROM employees e
JOIN departments d
  ON e.department_id = d.department_id;

Outer Join Filter Trap

-- Preserves departments with no employees
SELECT d.department_name, e.last_name
FROM departments d
LEFT OUTER JOIN employees e
  ON d.department_id = e.department_id;

-- Trap: WHERE condition on right table can turn it into an effective inner join
SELECT d.department_name, e.last_name
FROM departments d
LEFT OUTER JOIN employees e
  ON d.department_id = e.department_id
WHERE e.job_id = 'SA_REP';

-- Safer when the filter belongs to the matching condition
SELECT d.department_name, e.last_name
FROM departments d
LEFT OUTER JOIN employees e
  ON d.department_id = e.department_id
 AND e.job_id = 'SA_REP';

USING and NATURAL JOIN Traps

-- With USING, do not qualify the joined column in the select list
SELECT department_id, e.last_name, d.department_name
FROM employees e
JOIN departments d USING (department_id);

-- NATURAL JOIN joins on every column with the same name in both tables
SELECT employee_id, department_name
FROM employees
NATURAL JOIN departments;
TrapWhy it matters
Missing join conditionProduces Cartesian product
NATURAL JOINNew same-name columns can silently change results
Qualifying a USING columnInvalid in common Oracle exam syntax
Filtering outer-joined table in WHEREMay remove null-extended rows

Subqueries

Subquery Types

TypeReturnsOperators
Single-row subqueryOne row, one column=, >, <, >=, <=, <>
Multiple-row subqueryMany rows, one columnIN, ANY, ALL
Multiple-column subqueryMany columnsRow/value comparisons
Correlated subqueryReferences outer queryExecutes logically per outer row
Scalar subqueryOne valueCan appear where a single value is valid
Inline viewSubquery in FROMActs like a derived table
-- Single-row subquery
SELECT last_name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);

-- Multiple-row subquery
SELECT last_name
FROM employees
WHERE department_id IN (
  SELECT department_id
  FROM departments
  WHERE location_id = 1700
);

ANY, ALL, IN, EXISTS

OperatorMeaningExam interpretation
INEqual to any value in listSame idea as = ANY
> ANYGreater than at least one returned valueGreater than the minimum is enough
> ALLGreater than every returned valueGreater than the maximum
< ANYLess than at least one returned valueLess than the maximum
< ALLLess than every returned valueLess than the minimum
EXISTSTrue if subquery returns at least one rowCommon with correlated subqueries
NOT EXISTSTrue if no row returnedSafer than NOT IN when nulls may appear
SELECT e.employee_id, e.last_name
FROM employees e
WHERE EXISTS (
  SELECT 1
  FROM dependents d
  WHERE d.employee_id = e.employee_id
);

Subquery Traps

SituationResult / issue
Single-row operator with multi-row subqueryError
NOT IN and subquery returns NULLOften returns no rows due to unknown comparison
Correlated subquery missing correlationMay become uncorrelated and change result
Subquery in ORDER BYMust be valid scalar expression
Subquery in FROMNeeds aliasing/column handling for readability
-- Safer anti-match pattern
SELECT d.department_id
FROM departments d
WHERE NOT EXISTS (
  SELECT 1
  FROM employees e
  WHERE e.department_id = d.department_id
);

Set Operators

Set Operator Matrix

OperatorDuplicatesMeaning
UNIONRemoves duplicatesRows from either query
UNION ALLKeeps duplicatesRows from either query, faster conceptually because no duplicate elimination
INTERSECTRemoves duplicatesRows common to both queries
MINUSRemoves duplicatesRows in first query not in second
SELECT department_id FROM employees
UNION
SELECT department_id FROM departments;

Set Operator Rules

RuleExam point
Same number of columnsEach query must return same column count
Compatible data type groupsCorresponding columns must be compatible
Column names come from first queryFinal output headings use first select
ORDER BY appears at the endNot inside each component query unless using a valid subquery
Use column position or first-query alias in final ORDER BYEspecially useful for expressions
Parentheses control evaluationAvoid relying on precedence assumptions
SELECT employee_id AS id, last_name AS name FROM employees
UNION ALL
SELECT department_id, department_name FROM departments
ORDER BY name;

Row Limiting and Top-N Queries

TechniqueUseTrap
FETCH FIRST n ROWS ONLYModern row limiting after ORDER BYPut after ORDER BY
OFFSET n ROWSSkip rows before fetchOften paired with fetch
ROWNUMPseudocolumn assigned as rows are returnedROWNUM > 1 directly is a classic trap
Inline view with ROWNUMTop-N with older styleSort inside inline view, filter outside
SELECT employee_id, last_name, salary
FROM employees
ORDER BY salary DESC
FETCH FIRST 10 ROWS ONLY;

Older top-N pattern:

SELECT *
FROM (
  SELECT employee_id, last_name, salary
  FROM employees
  ORDER BY salary DESC
)
WHERE ROWNUM <= 10;

DML: INSERT, UPDATE, DELETE, MERGE

DML Command Reference

CommandPurposeKey syntax
INSERTAdd rowsVALUES or subquery
UPDATEChange rowsUse WHERE unless all rows should change
DELETERemove rowsUse WHERE unless all rows should be removed
MERGEInsert/update based on matchUseful for upsert-style logic
INSERT INTO departments (department_id, department_name)
VALUES (280, 'Research');

INSERT INTO departments (department_id, department_name)
SELECT 281, 'Analytics'
FROM dual;

UPDATE employees
SET salary = salary * 1.10
WHERE department_id = 60;

DELETE FROM employees
WHERE employee_id = 999;

MERGE Pattern

MERGE INTO bonuses b
USING employees e
   ON (b.employee_id = e.employee_id)
WHEN MATCHED THEN
  UPDATE SET b.salary = e.salary
WHEN NOT MATCHED THEN
  INSERT (employee_id, salary)
  VALUES (e.employee_id, e.salary);

Transaction Control

StatementEffect
COMMITMakes current transaction changes permanent
ROLLBACKUndoes uncommitted changes
SAVEPOINT nameMarks a point for partial rollback
ROLLBACK TO nameRolls back to savepoint
DDL statementCauses implicit commit behavior in Oracle
SAVEPOINT before_raise;

UPDATE employees
SET salary = salary * 1.05
WHERE department_id = 80;

ROLLBACK TO before_raise;
COMMIT;

DDL and Schema Objects

Table DDL

StatementPurposeExam note
CREATE TABLECreate tableDefine columns and constraints
ALTER TABLEModify tableAdd/drop/modify columns or constraints
DROP TABLERemove table definitionDDL; commits
TRUNCATE TABLERemove all rows efficientlyDDL; commits; no row-by-row delete
RENAMERename objectObject name change
CREATE TABLE projects (
  project_id   NUMBER CONSTRAINT projects_pk PRIMARY KEY,
  project_name VARCHAR2(100) NOT NULL,
  start_date   DATE DEFAULT SYSDATE,
  budget       NUMBER(10,2),
  status       VARCHAR2(20)
);

Constraint Reference

ConstraintPurposeColumn-level?Table-level?
NOT NULLRequires valueYesNo
UNIQUEPrevents duplicate non-null valuesYesYes
PRIMARY KEYUnique row identifier; not nullYesYes
FOREIGN KEYEnforces parent-child relationshipYesYes
CHECKEnforces conditionYesYes
CREATE TABLE order_items (
  order_id    NUMBER,
  line_id     NUMBER,
  product_id  NUMBER NOT NULL,
  quantity    NUMBER CHECK (quantity > 0),
  CONSTRAINT order_items_pk PRIMARY KEY (order_id, line_id),
  CONSTRAINT order_items_product_fk
    FOREIGN KEY (product_id) REFERENCES products(product_id)
);

Constraint Actions and Traps

FeatureMeaning
ON DELETE CASCADEDeleting parent deletes child rows
ON DELETE SET NULLDeleting parent sets child foreign key to null
No delete action specifiedParent delete fails if child rows exist
CHECK (col IS NOT NULL)Similar effect to NOT NULL, but not the same declaration
UNIQUE with nullsNull handling differs from ordinary equality intuition; do not treat null as a normal duplicate value

Views, Sequences, Synonyms, and Indexes

Views

View conceptMeaning
Simple viewBased on one table, no grouping/functions; more likely DML-capable
Complex viewJoins, groups, functions, expressions, or aggregates; DML may be restricted
CREATE OR REPLACE VIEWRecreates view without dropping privileges in the same way as drop/create
WITH CHECK OPTIONDML through view must satisfy view predicate
WITH READ ONLYPrevents DML through view
FORCECreate view even if base object is not currently valid
NOFORCERequires base object validity
CREATE OR REPLACE VIEW emp80 AS
SELECT employee_id, last_name, salary, department_id
FROM employees
WHERE department_id = 80
WITH CHECK OPTION;

Sequences

PseudocolumnMeaningTrap
sequence_name.NEXTVALGenerates next sequence valueAdvances the sequence
sequence_name.CURRVALCurrent session’s sequence valueRequires prior NEXTVAL in session
CREATE SEQUENCE project_seq
  START WITH 1
  INCREMENT BY 1;

INSERT INTO projects (project_id, project_name)
VALUES (project_seq.NEXTVAL, 'Migration');

Sequence exam points:

PointExplanation
Sequences are independent objectsNot automatically tied to one table unless used that way
Gaps can occurRollbacks, caching, or failed statements may leave gaps
CURRVAL is session-specificNot valid before NEXTVAL in that session

Indexes and Synonyms

ObjectPurposeNotes
IndexImproves access path for queriesOracle may create indexes for some constraints
Unique indexEnforces uniqueness when used for unique constraintsDistinguish object from constraint
Function-based indexIndex on expressionQuery must use matching expression conceptually
SynonymAlternative name for objectDoes not copy the object
Public synonymAvailable broadlyPrivileges still matter

Privileges and Access Control Basics

ConceptMeaning
System privilegeAllows an action, such as creating objects
Object privilegeAllows access to a specific object, such as SELECT on a table
RoleNamed group of privileges
GRANTGives privilege or role
REVOKERemoves privilege or role
WITH GRANT OPTIONLets grantee grant object privilege to others
WITH ADMIN OPTIONLets grantee administer a role/system privilege
GRANT SELECT ON employees TO analyst_role;
REVOKE SELECT ON employees FROM analyst_role;

High-Yield Error Patterns

PatternLikely problem
WHERE col = NULLShould use IS NULL
Aggregate in WHEREUse HAVING
Non-grouped column in aggregate queryAdd to GROUP BY or aggregate it
Single-row subquery returns multiple rowsUse multi-row operator or restrict subquery
NOT IN subquery returns nullUse NOT EXISTS pattern
Missing join conditionCartesian product
Filtering outer-joined table in WHERERemoves unmatched rows
CONCAT(a,b,c)Oracle CONCAT accepts two arguments
Using alias in WHEREAlias not available there
ROWNUM > 1 directlyNo first row can satisfy it
Set operator column mismatchSame column count and compatible types required
DDL followed by rollback expectationDDL has implicit commit behavior

Mini Decision Tables

WHERE vs HAVING

NeedClause
Filter individual rows before aggregationWHERE
Filter groups after aggregationHAVING
Use aggregate conditionHAVING
Improve grouping input setWHERE

Join vs Subquery

NeedPrefer
Return columns from multiple tablesJoin
Test existenceEXISTS / NOT EXISTS
Compare to aggregate valueScalar or single-row subquery
Anti-match with possible nullsNOT EXISTS
Combine similar result sets verticallySet operator

DELETE vs TRUNCATE vs DROP

NeedUse
Remove selected rows and allow transaction controlDELETE ... WHERE ...
Remove all rows as DDL-style operationTRUNCATE TABLE
Remove the table object itselfDROP TABLE

Exam-Day SQL Checklist

Before selecting an answer on Oracle 1Z0-071 SQL questions, check:

  1. Are nulls involved? If yes, verify IS NULL, aggregate behavior, and NOT IN logic.
  2. Are aggregates mixed with detail columns? If yes, verify GROUP BY.
  3. Is the filter row-level or group-level? Choose WHERE or HAVING.
  4. Is an alias used before it exists? Alias is safest in ORDER BY.
  5. Does a subquery return one row or many rows? Match the operator.
  6. Does an outer join still preserve unmatched rows after filtering?
  7. Do set operator queries have the same number and compatible types of columns?
  8. Does DDL appear in a transaction question? Remember implicit commit behavior.
  9. Is a date compared as text? Prefer explicit conversion with a format model.
  10. Is the question asking for syntax validity or result behavior? Check both.

Practical Next Step

Use this Quick Reference as a checklist while working original Oracle Database SQL (1Z0-071) practice questions. For every missed item, map the mistake back to one rule here: null logic, grouping, join preservation, subquery cardinality, set operator compatibility, or DDL/DML transaction behavior.

Browse Certification Practice Tests by Exam Family