Learn Oracle SQL: what changes compared with standard SQL
Most of what you write in Oracle is plain standard SQL: SELECT, WHERE, JOIN, GROUP BY, CASE and window functions read the same as in our practice database. This page shows, side by side, where Oracle has its own way, and which lesson lets you practise the idea behind it.
In short: Oracle has no LIMIT. You write FETCH FIRST 3 ROWS ONLY (or the older ROWNUM). Text columns are VARCHAR2, numbers NUMBER, and a DATE always carries a time as well. An empty string '' counts as NULL. Instead of an upsert with ON CONFLICT you use MERGE, and automatic IDs come from identity columns or sequences. Everything else you learn in this course carries over.
What is Oracle SQL?
Oracle SQL is the SQL that Oracle Database understands. The current release is called Oracle AI Database 26ai and succeeds Oracle Database 23ai. Older versions such as 19c differ in places, and this page says where. The core of the language follows the SQL standard, so the queries from this course work almost unchanged. Oracle adds its own data types, functions and a few older notations that you will find in existing reports and job interviews. LearnThisNext is not affiliated with Oracle; this page summarises the Oracle documentation for learners.
Why this course works for Oracle
Our exercises run on SQLite. Like Oracle, SQLite joins text with ||, knows COALESCE, CASE, CTEs with WITH, window functions and CREATE TABLE … AS SELECT. SELECT, WHERE, JOIN, GROUP BY, HAVING, subqueries and UNION are the same everywhere anyway. Where Oracle differs, you find the Oracle version below with a link to the lesson where you practise the concept. For MySQL, PostgreSQL and SQL Server there is a separate comparison: MySQL vs PostgreSQL vs SQL Server.
Try it now
The three most recent orders, newest first. In the practice database you finish with LIMIT 3; the Oracle version follows right below the exercise.
Task The dashboard should show the three most recent orders. Show order_id, order_date and status for those three orders, newest first.
orders 18 rows, 5 columns
| order_id | customer_id | order_date | status | employee_id |
|---|---|---|---|---|
| 1001 | 1 | 2026-01-08 | delivered | 3 |
| 1002 | 4 | 2026-01-12 | delivered | 4 |
| 1003 | 3 | 2026-01-20 | delivered | 3 |
| 1004 | 7 | 2026-02-03 | delivered | 4 |
| 1005 | 2 | 2026-02-11 | cancelled | 8 |
| 1006 | 1 | 2026-02-25 | delivered | 3 |
| 1007 | 10 | 2026-03-04 | delivered | 2 |
| 1008 | 5 | 2026-03-17 | delivered | 4 |
| 1009 | 8 | 2026-03-30 | delivered | 3 |
| 1010 | 6 | 2026-04-07 | delivered | 8 |
| 1011 | 12 | 2026-04-22 | delivered | 4 |
| 1012 | 3 | 2026-05-06 | delivered | 3 |
| 1013 | 9 | 2026-05-19 | cancelled | 8 |
| 1014 | 7 | 2026-06-02 | shipped | 4 |
| 1015 | 1 | 2026-06-10 | shipped | 3 |
| 1016 | 11 | 2026-06-12 | open | NULL |
| 1017 | 4 | 2026-06-13 | open | NULL |
| 1018 | 10 | 2026-06-14 | open | NULL |
In Oracle, the same query ends with the row limiting clause from the SQL standard, available since Oracle Database 12c:
-- Oracle
SELECT order_id, order_date, status
FROM orders
ORDER BY order_date DESC
FETCH FIRST 3 ROWS ONLY;
The differences at a glance
| Topic | Here (SQLite) | Oracle | Practise in |
|---|---|---|---|
| First n rows | LIMIT 3 | FETCH FIRST 3 ROWS ONLY, older: ROWNUM | ORDER BY |
| Skip rows | LIMIT 10 OFFSET 20 | OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY | ORDER BY |
| Expression without a table | SELECT 2 * 3; | SELECT 2 * 3 FROM dual; (FROM optional since Release 23) | Calculations |
| Text, numbers, dates | TEXT, INTEGER, REAL, dates as text | VARCHAR2(100), NUMBER(10,2), DATE with time | CREATE TABLE |
| Empty text | '' is not NULL | '' is NULL | NULL |
| Joining text | || | || or CONCAT(); NULL is ignored | String functions |
| Replacement for NULL | COALESCE() | COALESCE() or NVL() | NULL and COALESCE |
| Month from a date | strftime('%Y-%m', order_date) | TO_CHAR(order_date, 'YYYY-MM') | Date functions |
| Automatic ID | INTEGER PRIMARY KEY | GENERATED ALWAYS AS IDENTITY or a sequence | Primary keys |
| Insert or update | ON CONFLICT … DO UPDATE | MERGE | Upsert |
| Several rows in one INSERT | VALUES (…), (…) | same since 23ai, before: INSERT … SELECT … FROM dual UNION ALL … | INSERT |
| UPDATE with values from another table | subquery in SET | subquery, MERGE, or UPDATE … FROM since 23ai | UPDATE |
| Outer join | LEFT JOIN | LEFT JOIN, in old code (+) | LEFT JOIN |
| Rows of the first query only | EXCEPT | MINUS (EXCEPT also in current versions) | UNION |
| Empty a table | DELETE FROM t; | TRUNCATE TABLE t; (cannot be rolled back) | DELETE |
| Copy a table, rename a column | CREATE TABLE … AS SELECT, RENAME COLUMN | same | ALTER TABLE |
| Hierarchies | WITH RECURSIVE | WITH without RECURSIVE, or CONNECT BY | Recursive queries |
Where Oracle differs, with examples
The first rows: FETCH FIRST and ROWNUM
-- Here
SELECT name, price FROM products ORDER BY price DESC LIMIT 5;
-- Oracle
SELECT name, price FROM products ORDER BY price DESC FETCH FIRST 5 ROWS ONLY;
SELECT name, price FROM products ORDER BY price DESC OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;
In older code you will see ROWNUM. It numbers rows in the order Oracle reads them, before ORDER BY. That is why WHERE ROWNUM <= 5 ORDER BY price DESC returns five arbitrary rows, sorted afterwards. The documentation's fix is to sort inside a subquery and filter outside:
SELECT * FROM (SELECT name, price FROM products ORDER BY price DESC)
WHERE ROWNUM <= 5;
A condition like ROWNUM > 1 never returns a row, according to the documentation.
DUAL: a table with exactly one row
For years, Oracle required a FROM clause in every SELECT. For calculations without a table there is DUAL, a table with exactly one row. Since Release 23 the FROM clause is optional for such queries, but you will still find FROM dual in nearly every script and textbook.
SELECT SYSDATE FROM dual; -- current date and time
SELECT ROUND(19.99 * 1.19, 2) FROM dual;
SELECT 2 * 3; -- since Release 23 (23ai)
Data types: VARCHAR2, NUMBER and DATE
-- Oracle
CREATE TABLE categories (
category_id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR2(100) NOT NULL,
margin NUMBER(5,2),
created DATE DEFAULT SYSDATE
);
VARCHAR2 is variable-length text; Oracle advises against plain VARCHAR because its meaning may change in a future release. NUMBER(p,s) covers whole numbers and decimals. Important for queries: a DATE stores year, month, day, hour, minute and second. If a value contains a time, WHERE order_date = DATE '2026-06-18' misses it; TRUNC(order_date) removes the time first.
An empty string is NULL
Oracle treats a string of length zero as NULL. In our practice database, '' and NULL are two different things. In Oracle, WHERE phone = '' never finds a row; you write WHERE phone IS NULL. The documentation adds that this may change in future releases and recommends not treating empty strings as NULL in your own logic. The safe habit for both worlds: test for missing values with IS NULL.
Joining text: || and CONCAT
SELECT first_name || ' ' || last_name AS full_name FROM employees;
SELECT CONCAT(first_name, last_name) FROM employees;
|| works as it does here. One difference catches people out: in SQLite, 'Smith' || NULL gives NULL; in Oracle it gives 'Smith', because NULL counts as an empty string. Only two NULLs give NULL. In the current documentation CONCAT accepts two or more arguments; in 19c it takes exactly two.
NVL and COALESCE
SELECT name, NVL(phone, 'no number') AS phone FROM customers; -- Oracle only
SELECT name, COALESCE(phone, 'no number') AS phone FROM customers; -- everywhere
NVL takes exactly two values, COALESCE any number of them and returns the first that is not NULL. Both exist in Oracle and both are on the exam list. In the practice database, NVL gets the reply: “NVL() does not exist in this practice database (SQLite). For a replacement for NULL, use COALESCE(column, replacement).”
Dates: TO_CHAR, TO_DATE and arithmetic
-- Here (dates stored as text)
SELECT strftime('%Y-%m', order_date) AS order_month FROM orders;
SELECT date(order_date, '+7 days') FROM orders;
-- Oracle
SELECT TO_CHAR(order_date, 'YYYY-MM') AS order_month FROM orders;
SELECT order_date + 7 FROM orders; -- one week later
SELECT DATE '2026-06-30' - DATE '2026-06-01' FROM dual; -- 29 (days)
SELECT TO_DATE('17.11.2026', 'DD.MM.YYYY') FROM dual; -- text to date
Oracle reads a number added to a date as days: SYSDATE + 1 is tomorrow, and subtracting two dates returns the days between them. The literal DATE '2026-06-18' always uses the form YYYY-MM-DD and has no time part.
Automatic IDs: identity columns and sequences
-- identity column (since Oracle Database 12c)
CREATE TABLE notes (
note_id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
text VARCHAR2(400)
);
-- sequence: a number generator of its own
CREATE SEQUENCE order_seq START WITH 2001 INCREMENT BY 1;
INSERT INTO orders (order_id, customer_id, order_date, status)
VALUES (order_seq.NEXTVAL, 4, DATE '2026-11-17', 'open');
With ALWAYS, Oracle rejects a value you supply yourself; with BY DEFAULT, your value wins. Sequences are separate database objects: NEXTVAL returns the next number, CURRVAL the number NEXTVAL last returned in your session. In our course the database assigns the ID itself; the idea is the same.
MERGE instead of ON CONFLICT
-- Here
INSERT INTO products (product_id, name, price, stock)
VALUES (12, 'Desk lamp', 39.90, 5)
ON CONFLICT (product_id) DO UPDATE SET stock = stock + excluded.stock;
-- Oracle
MERGE INTO products p
USING goods_in g
ON (p.product_id = g.product_id)
WHEN MATCHED THEN UPDATE SET p.stock = p.stock + g.quantity
WHEN NOT MATCHED THEN INSERT (product_id, name, price, stock)
VALUES (g.product_id, g.name, g.price, g.quantity);
MERGE compares a source with the target table: matching rows are updated, missing ones inserted. The condition after ON goes in parentheses. You learn the idea behind it in the upsert lesson.
Several rows in one INSERT
-- Here, and in Oracle since 23ai
INSERT INTO customers (name, city, country, segment)
VALUES ('Lorenz Animal Clinic', 'Denver', 'USA', 'Business'),
('Emma Fisher', 'Austin', 'USA', 'Consumer');
-- Oracle before 23ai: one SELECT per row from DUAL
INSERT INTO customers (name, city, country, segment)
SELECT 'Lorenz Animal Clinic', 'Denver', 'USA', 'Business' FROM dual UNION ALL
SELECT 'Emma Fisher', 'Austin', 'USA', 'Consumer' FROM dual;
INSERT ALL is something else: one source row goes into several INTO clauses, even into different tables. The exam calls this a multi-table insert.
UPDATE with values from another table
The subquery version you practise in the exercise below runs unchanged in Oracle. Since 23ai, Oracle also accepts a direct join with FROM; before that, MERGE was the usual route:
-- Oracle since 23ai
UPDATE order_items i
SET i.unit_price = p.price
FROM products p
WHERE i.product_id = p.product_id;
Outer joins with (+)
-- standard, also in Oracle
SELECT c.name, o.order_id
FROM customers c LEFT JOIN orders o ON o.customer_id = c.customer_id;
-- old Oracle notation, same result
SELECT c.name, o.order_id
FROM customers c, orders o
WHERE c.customer_id = o.customer_id(+);
The (+) goes on the side that may be missing. Oracle itself recommends the LEFT JOIN syntax, and you cannot mix both in one query block. You will still meet (+) in older reports and on the exam.
MINUS, TRUNCATE and table operations
- MINUS: rows of the first query that are missing from the second. The current documentation lists EXCEPT as a synonym; the 19c documentation only knows MINUS.
- TRUNCATE TABLE: removes all rows at once. Unlike DELETE, it cannot be rolled back.
- CREATE TABLE … AS SELECT and ALTER TABLE … RENAME COLUMN … TO … look the same as in our CREATE TABLE and ALTER TABLE lessons.
Hierarchies: WITH and CONNECT BY
-- Oracle: recursive WITH, without the word RECURSIVE, with a column list
WITH chain (employee_id, last_name, lvl) AS (
SELECT employee_id, last_name, 1 FROM employees WHERE manager_id IS NULL
UNION ALL
SELECT e.employee_id, e.last_name, c.lvl + 1
FROM employees e JOIN chain c ON e.manager_id = c.employee_id
)
SELECT * FROM chain;
-- Oracle's own notation
SELECT last_name, LEVEL
FROM employees
START WITH manager_id IS NULL
CONNECT BY PRIOR employee_id = manager_id;
Oracle requires UNION ALL between the anchor and the recursive part. CONNECT BY is older and specific to Oracle; START WITH names the top of the tree, PRIOR the parent row. The concept is the same as in our lesson on recursive queries.
Exercise: a phone list without gaps
Solve it with COALESCE. In Oracle you could also write NVL. Bear in mind that a phone number stored as '' would already be NULL there.
Task Sales wants a phone list: show the name and phone of every customer. Where no number is on file, the list should say no number instead of leaving the cell blank.
customers 12 rows, 7 columns
| customer_id | name | city | country | customer_since | segment | phone |
|---|---|---|---|---|---|---|
| 1 | Harbor Fremont Partners | Boston | USA | 2021-03-15 | Business | 617-555-0142 |
| 2 | Emily Carter | Chicago | USA | 2022-07-01 | Consumer | NULL |
| 3 | Riverside County Office | Riverside | USA | 2020-11-20 | Government | 951-555-0110 |
| 4 | Raj Patel | Leeds | UK | 2023-01-09 | Consumer | 0113 496 0123 |
| 5 | Lakeview Hotel Ltd | Manchester | UK | 2022-04-18 | Business | 0161 496 0456 |
| 6 | Olivia Brooks | Austin | USA | 2024-02-27 | Consumer | NULL |
| 7 | Greene & Shaw LLP | London | UK | 2021-09-05 | Business | 020 7946 0321 |
| 8 | Maple Grove High School | Austin | USA | 2023-08-14 | School | 512-555-0187 |
| 9 | Chloe Evans | Boston | USA | 2025-05-30 | Consumer | 617-555-0199 |
| 10 | Northline Printing Co | Toronto | Canada | 2020-06-12 | Business | 416-555-0133 |
| 11 | Daniel Kim | Seattle | USA | 2024-10-03 | Consumer | NULL |
| 12 | Westbrook Dental Clinic | Chicago | USA | 2022-12-01 | Business | 312-555-0164 |
Exercise: update prices from another table
This correlated subquery in SET and the IN list in WHERE run in Oracle exactly as written. The exam topics list this pattern as “update and delete rows using correlated subqueries”.
Task Before shipping, every open order should be billed at the current list price. In order_items, set unit_price to the product's price from products, but only for items that belong to orders whose status in orders is open. After Run or Check you will see the items whose price actually changed.
order_items 38 rows, 4 columns
| order_id | product_id | quantity | unit_price |
|---|---|---|---|
| 1001 | 1 | 40 | 4.79 |
| 1001 | 3 | 25 | 2.79 |
| 1001 | 6 | 4 | 24.9 |
| 1002 | 2 | 2 | 3.49 |
| 1002 | 10 | 3 | 5.49 |
| 1003 | 1 | 60 | 4.69 |
| 1003 | 11 | 6 | 84.9 |
| 1003 | 3 | 50 | 2.59 |
| 1004 | 4 | 3 | 179 |
| 1004 | 9 | 3 | 269 |
| 1005 | 5 | 1 | 449 |
| 1006 | 1 | 30 | 4.79 |
| 1006 | 7 | 10 | 6.99 |
| 1007 | 8 | 2 | 219 |
| 1007 | 11 | 4 | 89.9 |
| 1007 | 1 | 20 | 4.99 |
| 1008 | 4 | 6 | 175 |
| 1008 | 2 | 5 | 3.49 |
| 1009 | 10 | 120 | 4.99 |
| 1009 | 2 | 40 | 3.19 |
| 1009 | 9 | 2 | 279 |
| 1010 | 7 | 2 | 6.99 |
| 1010 | 2 | 1 | 3.49 |
| 1011 | 12 | 1 | 129 |
| 1011 | 1 | 10 | 4.99 |
| 1011 | 3 | 12 | 2.79 |
| 1012 | 6 | 8 | 23.9 |
| 1012 | 1 | 40 | 4.69 |
| 1013 | 9 | 1 | 279 |
| 1014 | 5 | 2 | 439 |
| 1014 | 4 | 2 | 179 |
| 1015 | 1 | 50 | 4.79 |
| 1015 | 11 | 2 | 89.9 |
| 1016 | 10 | 4 | 5.49 |
| 1017 | 2 | 3 | 3.49 |
| 1017 | 7 | 2 | 6.99 |
| 1018 | 1 | 80 | 4.79 |
| 1018 | 6 | 10 | 24.9 |
products 12 rows, 5 columns
| product_id | name | category | price | stock |
|---|---|---|---|---|
| 1 | Copy paper, 500 sheets | Paper | 4.99 | 420 |
| 2 | Blue ballpoint pens, 10-pack | Writing | 3.49 | 310 |
| 3 | Lever arch file, gray | Filing | 2.79 | 185 |
| 4 | Comfort office chair | Furniture | 189 | 12 |
| 5 | Standing desk | Furniture | 449 | 5 |
| 6 | Black ink cartridge | Printer supplies | 24.9 | 64 |
| 7 | Yellow sticky notes, 12 pads | Writing | 6.99 | 0 |
| 8 | Mono laser printer L30 | Electronics | 219 | 8 |
| 9 | 27-inch monitor | Electronics | 279 | 15 |
| 10 | Notebook A5, ruled | Paper | 5.49 | 140 |
| 11 | Black toner XL | Printer supplies | 89.9 | 22 |
| 12 | Cross-cut shredder | Electronics | 129 | 0 |
orders 18 rows, 5 columns
| order_id | customer_id | order_date | status | employee_id |
|---|---|---|---|---|
| 1001 | 1 | 2026-01-08 | delivered | 3 |
| 1002 | 4 | 2026-01-12 | delivered | 4 |
| 1003 | 3 | 2026-01-20 | delivered | 3 |
| 1004 | 7 | 2026-02-03 | delivered | 4 |
| 1005 | 2 | 2026-02-11 | cancelled | 8 |
| 1006 | 1 | 2026-02-25 | delivered | 3 |
| 1007 | 10 | 2026-03-04 | delivered | 2 |
| 1008 | 5 | 2026-03-17 | delivered | 4 |
| 1009 | 8 | 2026-03-30 | delivered | 3 |
| 1010 | 6 | 2026-04-07 | delivered | 8 |
| 1011 | 12 | 2026-04-22 | delivered | 4 |
| 1012 | 3 | 2026-05-06 | delivered | 3 |
| 1013 | 9 | 2026-05-19 | cancelled | 8 |
| 1014 | 7 | 2026-06-02 | shipped | 4 |
| 1015 | 1 | 2026-06-10 | shipped | 3 |
| 1016 | 11 | 2026-06-12 | open | NULL |
| 1017 | 4 | 2026-06-13 | open | NULL |
| 1018 | 10 | 2026-06-14 | open | NULL |
This exercise is part of Premium.
Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.
See Premium Already Premium? Log in
The first exercise in this lesson is free.
Trying Oracle for free
- FreeSQL: Oracle's browser worksheet at freesql.com, described on the Oracle AI Database Free page as a free sandbox for developing SQL. The former Live SQL address livesql.oracle.com now leads there.
- Oracle AI Database 26ai Free: a free edition to install, for Windows, Linux and as a container image (on a Mac via Docker). Limits according to Oracle: up to 2 CPU threads, 2 GB of database RAM and 12 GB of user data.
Our practice database is not an Oracle database. It is enough for learning the logic of SQL; for the Oracle-specific notations on this page, use one of the two tools above.
Oracle certification
If you are aiming for the Oracle Database SQL exam (1Z0-071): Oracle Database SQL Certified Associate (1Z0-071) lists the official exam topics and maps each one to our lessons, including what our course does not cover.
FAQ
Is Oracle SQL different from SQL?
Oracle SQL is SQL with Oracle-specific additions. SELECT, WHERE, JOIN, GROUP BY, subqueries and window functions are written as in the standard. The differences are in data types, some functions (NVL, TO_CHAR, TO_DATE), row limiting and older notations such as (+) and CONNECT BY.
How do I select the top 10 rows in Oracle?
Sort first, then limit: ORDER BY … FETCH FIRST 10 ROWS ONLY. In versions before 12c, sort in a subquery and filter outside with WHERE ROWNUM <= 10.
How do I insert multiple rows in Oracle?
Since 23ai with several row groups after VALUES, as in our course. In older versions with INSERT INTO … SELECT … FROM dual UNION ALL SELECT … FROM dual.
How do I update with a join in Oracle?
With a correlated subquery in SET (works in every version), with MERGE, or since 23ai with UPDATE … SET … FROM other_table WHERE ….
Does SELECT INTO create a table in Oracle?
No. To copy a table, use CREATE TABLE new_table AS SELECT …. SELECT … INTO belongs to PL/SQL, Oracle's programming language, and fills variables there.
Which version does this page cover?
We checked everything against the Oracle SQL Language Reference for Oracle AI Database 26ai. Where older versions behave differently, the text names the version (12c, 19c, 23ai).
Sources: Oracle AI Database SQL Language Reference 26ai on docs.oracle.com (SELECT with row_limiting_clause and values_clause, ROWNUM Pseudocolumn, Selecting from the DUAL Table, Data Types, Nulls, Concatenation Operator, CONCAT, NVL, COALESCE, TO_CHAR (datetime), TO_DATE, Literals, CREATE TABLE identity_clause, CREATE SEQUENCE, Sequence Pseudocolumns, MERGE, INSERT, UPDATE, Joins, The UNION [ALL], INTERSECT, MINUS Operators, TRUNCATE TABLE, ALTER TABLE, Hierarchical Queries), PL/SQL Language Reference (SELECT INTO Statement), SQL Language Reference 12.1 and 19c for the version notes, Oracle AI Database New Features (SQL), Oracle tutorial “Oracle Database 23ai SQL features” on docs.oracle.com/en/learn, oracle.com/database/free, freesql.com; checked 17 November 2026.