Oracle SQL Practice Test

โ–ถ

Oracle SQL 2025 Guide

Quick Reference: Review the sections below for a comprehensive guide to SQL โ€” covering exam structure, preparation strategies, and what to expect on test day.

What Is Oracle SQL?

Oracle SQL is the implementation of SQL (Structured Query Language) used in Oracle Database โ€” one of the world's most widely deployed enterprise relational database management systems. While Oracle SQL adheres to the ANSI SQL standard, it includes Oracle-specific extensions, functions, and syntax that differ from other database platforms such as MySQL, PostgreSQL, and SQL Server. Understanding Oracle-specific SQL is essential for developers, database administrators (DBAs), and data analysts working in Oracle environments.

Oracle Database is a dominant force in enterprise computing โ€” used by the vast majority of Fortune 500 companies, government agencies, financial institutions, and healthcare systems for mission-critical data management. SQL is the language used to interact with Oracle Database: querying data, inserting and updating records, managing database objects, and controlling access. Proficiency in Oracle SQL is a foundational requirement for virtually every Oracle-related technology role.

Oracle SQL vs. Standard SQL

Oracle SQL extends the ANSI SQL standard with Oracle-specific features: ROWNUM and ROW_NUMBER() for row limiting (Oracle uses ROWNUM rather than the LIMIT keyword); the DUAL table โ€” a single-row, single-column table used for evaluating expressions and functions that don't require a real table; NVL() and NVL2() โ€” Oracle's null-handling functions (equivalent to COALESCE() in standard SQL); DECODE() โ€” Oracle's conditional expression function; hierarchical queries using CONNECT BY and START WITH โ€” for querying tree-structured data; and Oracle-specific date/time functions (TO_DATE(), TO_CHAR(), TRUNC(), ADD_MONTHS()). Developers migrating between Oracle and other database platforms must adjust for these syntactic differences.

Oracle SQL SELECT Statements

The SELECT statement is the foundation of SQL query writing. Understanding SELECT syntax, clauses, and filtering is the starting point for all Oracle SQL work.

Basic SELECT Syntax

The basic Oracle SQL SELECT statement: SELECT column1, column2 FROM table_name WHERE condition ORDER BY column1; The SELECT clause specifies which columns to retrieve. The asterisk (*) selects all columns: SELECT * FROM employees; The FROM clause specifies the table. The WHERE clause filters rows based on conditions. The ORDER BY clause sorts results. A complete example: SELECT employee_id, first_name, last_name, salary FROM employees WHERE department_id = 50 ORDER BY salary DESC; This retrieves the employee ID, name, and salary for all employees in department 50, sorted from highest to lowest salary.

WHERE Clause Operators

WHERE clauses use comparison operators (=, !=, >, <, >=, <=) and logical operators (AND, OR, NOT). Additional important WHERE clause conditions: BETWEEN โ€” WHERE salary BETWEEN 50000 AND 100000 (inclusive); IN โ€” WHERE department_id IN (10, 20, 30); LIKE โ€” pattern matching with % (any string) and _ (any single character): WHERE last_name LIKE 'Sm%'; IS NULL / IS NOT NULL โ€” WHERE manager_id IS NULL; NOT IN โ€” WHERE department_id NOT IN (10, 20).

Column Aliases and Expressions

Column aliases rename output columns: SELECT first_name || ' ' || last_name AS full_name, salary * 12 AS annual_salary FROM employees; The || operator is Oracle's string concatenation operator (standard SQL uses CONCAT()). AS keyword creates the alias. Arithmetic expressions can be used directly in SELECT: salary * 1.10 calculates a 10% salary increase.

ROWNUM and Limiting Results

Oracle uses ROWNUM (not LIMIT) to restrict result sets: SELECT * FROM employees WHERE ROWNUM <= 10; returns only the first 10 rows. For pagination, use a subquery with ORDER BY and ROW_NUMBER(): SELECT * FROM (SELECT employee_id, first_name, salary, ROW_NUMBER() OVER (ORDER BY salary DESC) AS rn FROM employees) WHERE rn BETWEEN 11 AND 20; This pattern is essential for paginating large result sets in Oracle.

SQL Key Statistics

๐Ÿ…
OCP
Oracle Certified Professional: the most recognized Oracle DBA certification
๐Ÿ—„๏ธ
DUAL
Oracle's special single-row table for evaluating expressions without a real table
โš™๏ธ
||
Oracle string concatenation operator (vs. CONCAT() in standard SQL)
๐Ÿ”ข
ROWNUM
Oracle's row-limiting mechanism (vs. LIMIT in MySQL/PostgreSQL)
Oracle SQL Test 1
Oracle SQL Test 2
Oracle SQL Oracle SQL SELECT Statements
Oracle SQL Oracle SQL Joins and Subqueries

Oracle SQL JOINs and Subqueries

JOINs and subqueries are fundamental to relational database querying โ€” they allow data from multiple tables to be combined and analyzed together.

Types of JOINs

INNER JOIN โ€” returns only rows where there is a match in both tables: SELECT e.first_name, d.department_name FROM employees e INNER JOIN departments d ON e.department_id = d.department_id; LEFT OUTER JOIN โ€” returns all rows from the left table plus matched rows from the right table (unmatched right table rows show NULL): SELECT e.first_name, d.department_name FROM employees e LEFT JOIN departments d ON e.department_id = d.department_id; RIGHT OUTER JOIN โ€” all rows from the right table, matched rows from the left.

FULL OUTER JOIN โ€” all rows from both tables, with NULLs where there is no match. CROSS JOIN โ€” Cartesian product of both tables (every row in table A matched with every row in table B). SELF JOIN โ€” joining a table to itself: useful for organizational hierarchies: SELECT e.first_name AS employee, m.first_name AS manager FROM employees e JOIN employees m ON e.manager_id = m.employee_id; Oracle also supports the older syntax using WHERE clause join conditions (e.g., WHERE e.dept_id = d.dept_id(+) for outer joins), but the ANSI JOIN syntax above is preferred.

Subqueries

A subquery is a query nested inside another query. Single-row subqueries return one row and use comparison operators: SELECT first_name, salary FROM employees WHERE salary > (SELECT AVG(salary) FROM employees); Multiple-row subqueries use IN, ANY, or ALL: SELECT first_name FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE location_id = 1700); Correlated subqueries reference the outer query in the subquery โ€” they execute once per row of the outer query: SELECT first_name, salary FROM employees e WHERE salary > (SELECT AVG(salary) FROM employees WHERE department_id = e.department_id); This finds employees earning more than the average salary in their own department.

Oracle SQL Functions

Oracle SQL includes a rich set of built-in functions for data manipulation and analysis. Understanding commonly used functions is essential for both daily SQL work and certification exams.

String Functions

UPPER(string) / LOWER(string) โ€” converts case: UPPER('hello') returns 'HELLO'. SUBSTR(string, position, length) โ€” extracts a substring: SUBSTR('Oracle', 1, 3) returns 'Ora'. LENGTH(string) โ€” returns string length: LENGTH('Oracle') returns 6. TRIM(string) โ€” removes leading and trailing spaces. REPLACE(string, search, replacement) โ€” replaces occurrences of a substring. LPAD / RPAD โ€” pads a string on the left or right to a specified length: LPAD('42', 5, '0') returns '00042'. INSTR(string, substring) โ€” returns the position of the first occurrence of substring.

Numeric Functions

ROUND(n, decimals) โ€” rounds to specified decimal places: ROUND(3.14159, 2) returns 3.14. TRUNC(n, decimals) โ€” truncates without rounding: TRUNC(3.14159, 2) returns 3.14, TRUNC(3.9) returns 3. MOD(m, n) โ€” returns the remainder of m divided by n. ABS(n) โ€” absolute value. POWER(m, n) โ€” m raised to the power of n. CEIL(n) / FLOOR(n) โ€” rounds up/down to the nearest integer.

Date Functions

SYSDATE โ€” returns the current date and time from the database server. TRUNC(date) โ€” truncates a date to midnight (removes time component). ADD_MONTHS(date, n) โ€” adds n months to a date. MONTHS_BETWEEN(date1, date2) โ€” returns the number of months between two dates. TO_DATE('string', 'format') โ€” converts a string to a date: TO_DATE('2025-01-15', 'YYYY-MM-DD'). TO_CHAR(date, 'format') โ€” converts a date to a formatted string: TO_CHAR(SYSDATE, 'DD-MON-YYYY'). LAST_DAY(date) โ€” returns the last day of the month for a given date.

Aggregate Functions and GROUP BY

Aggregate functions compute summary values across multiple rows: COUNT(*) โ€” total row count; SUM(column) โ€” sum of values; AVG(column) โ€” average value; MAX(column) / MIN(column) โ€” maximum/minimum value. GROUP BY groups rows sharing the same value into summary rows: SELECT department_id, AVG(salary), COUNT(*) FROM employees GROUP BY department_id ORDER BY AVG(salary) DESC; The HAVING clause filters groups (like WHERE but for aggregate results): SELECT department_id, AVG(salary) FROM employees GROUP BY department_id HAVING AVG(salary) > 60000;

Oracle SQL Certification

Oracle offers several certification tracks for SQL and database professionals through Oracle University. Oracle certifications are widely recognized in enterprise IT and carry significant weight with employers who use Oracle Database.

Oracle Database SQL Certification (OCA)

Oracle Certified Associate (OCA) Oracle Database SQL is the entry-level Oracle SQL certification. It validates foundational SQL skills: writing SELECT statements, filtering and sorting data, using single-row and group functions, displaying data from multiple tables using JOINs, using subqueries, manipulating data with DML (INSERT, UPDATE, DELETE, MERGE), managing database objects (CREATE TABLE, ALTER, DROP), and controlling user access with DCL (GRANT, REVOKE). The Oracle Database SQL exam (1Z0-071) consists of multiple-choice questions and does not require a formal training course โ€” candidates can self-study using Oracle's SQL documentation, practice environments (Oracle Live SQL is free), and practice exams.

Oracle Certified Professional (OCP)

The OCP track covers advanced Oracle Database administration and development. OCP DBA tracks include Oracle Database Administration I and II exams, covering installation, configuration, storage management, performance tuning, backup and recovery, and security. The OCP is the most widely recognized Oracle DBA credential and is frequently a requirement or strong preference for senior DBA roles.

Free Oracle Practice Environment

Oracle Live SQL (livesql.oracle.com) provides a free browser-based Oracle SQL environment โ€” no installation required. Candidates can run SQL queries against sample databases, practice DML and DDL, and work through Oracle's official SQL tutorials. Using Oracle Live SQL during study allows candidates to validate their understanding of Oracle-specific syntax and see exactly how queries execute in a real Oracle environment.

SQL Checklist

Master SELECT syntax: columns, aliases, expressions, WHERE conditions, ORDER BY, and ROWNUM
Practice all JOIN types: INNER, LEFT, RIGHT, FULL OUTER, SELF, and CROSS JOIN
Learn single-row functions: string (SUBSTR, UPPER, LENGTH), numeric (ROUND, TRUNC, MOD), date (TO_DATE, ADD_MONTHS, SYSDATE)
Practice GROUP BY and aggregate functions: COUNT, SUM, AVG, MAX, MIN, and HAVING clause
Write single-row, multiple-row, and correlated subqueries with confidence
Understand Oracle-specific syntax: DUAL table, || concatenation, ROWNUM, NVL(), DECODE()
Practice DML statements: INSERT INTO, UPDATE SET, DELETE FROM, MERGE INTO
Learn DDL basics: CREATE TABLE, ALTER TABLE, DROP TABLE, constraints (PK, FK, UNIQUE, NOT NULL)
Use Oracle Live SQL (free) to practice queries in a real Oracle environment
Take practice exams aligned to Oracle Database SQL certification (1Z0-071)
Free Oracle SQL Test
Oracle SQL Oracle SQL Functions
Oracle SQL Oracle SQL Functions 2

SQL Pros and Cons

Pros

  • SQL has a defined, publicly available content blueprint โ€” candidates know exactly what to prepare for
  • Multiple preparation pathways (self-study, courses, coaching) accommodate different learning styles and schedules
  • A growing ecosystem of study resources means candidates at any budget level can access quality preparation materials
  • Clear score reporting allows candidates to identify specific strengths and weaknesses for targeted remediation
  • Professional recognition associated with strong performance provides tangible career and academic benefits

Cons

  • The scope of tested content requires substantial preparation time that competes with existing professional or academic commitments
  • No single resource covers the full content scope โ€” candidates typically need multiple study tools for comprehensive preparation
  • Test anxiety and exam-day performance variability mean preparation effort does not always translate linearly to scores
  • Registration, preparation, and potential retake costs accumulate into a significant financial investment
  • Content and format can change between exam versions, making older preparation materials less reliable

Oracle SQL Questions and Answers

What is Oracle SQL?

Oracle SQL is the implementation of SQL (Structured Query Language) used in Oracle Database โ€” one of the world's most widely used enterprise relational database management systems. Oracle SQL adheres to the ANSI SQL standard but includes Oracle-specific extensions: the DUAL table, ROWNUM for row limiting, NVL() for null handling, DECODE() for conditional expressions, and Oracle-specific date functions (TO_DATE, ADD_MONTHS, SYSDATE). Oracle Database is used by the vast majority of Fortune 500 companies and is a dominant platform in enterprise, financial, healthcare, and government computing.

What is the DUAL table in Oracle?

DUAL is a special single-row, single-column table that exists in Oracle Database. It is used to evaluate expressions and functions that don't require data from a real table. For example: SELECT SYSDATE FROM DUAL; returns the current date and time. SELECT UPPER('hello') FROM DUAL; returns 'HELLO'. SELECT 2 + 2 FROM DUAL; returns 4. DUAL is Oracle-specific โ€” other databases like MySQL and PostgreSQL don't require a dummy table for expression evaluation.

What is the difference between ROWNUM and ROW_NUMBER() in Oracle?

ROWNUM is a pseudocolumn that assigns sequential numbers to rows as they are returned by a query, before ORDER BY is applied โ€” making it unreliable for ordered pagination. ROW_NUMBER() is an analytic function that assigns sequential numbers to rows within a result set partition, after ORDER BY is applied: SELECT * FROM (SELECT employee_id, ROW_NUMBER() OVER (ORDER BY salary DESC) AS rn FROM employees) WHERE rn BETWEEN 11 AND 20. ROW_NUMBER() with a subquery is the correct approach for pagination in Oracle; ROWNUM alone is used only to limit total result count.

What Oracle SQL certification should I get?

For developers and SQL users: the Oracle Database SQL certification (OCA, exam 1Z0-071) validates foundational SQL skills. For database administrators: the Oracle Certified Professional (OCP) DBA tracks cover advanced database administration. For Java developers using Oracle: Oracle Certified Professional Java SE Developer certifications are available. Start with the Oracle Database SQL exam if you are building SQL fundamentals; progress to OCP DBA if you plan to manage Oracle database infrastructure.

How do I practice Oracle SQL for free?

Oracle Live SQL (livesql.oracle.com) is a free browser-based Oracle SQL environment โ€” no installation or Oracle license required. It includes sample schemas (HR, OE, SH) and allows you to run any SQL statement in a real Oracle database engine. Oracle also provides free developer VMs and Oracle XE (Express Edition) โ€” a free, full-featured Oracle database for learning and development. Use these environments to practice SQL syntax, test queries, and verify that your Oracle-specific syntax is correct.

What is the NVL function in Oracle?

NVL(expression, replacement) is Oracle's null-handling function โ€” it returns the replacement value if expression is NULL, otherwise returns expression. For example: NVL(commission_pct, 0) returns 0 for employees with no commission. NVL2(expression, value_if_not_null, value_if_null) extends this: NVL2(commission_pct, 'Has Commission', 'No Commission'). These are Oracle-specific functions; standard SQL uses COALESCE(expression, replacement), which also works in Oracle but NVL is more common in Oracle-specific code.
โ–ถ Start Quiz