What’s new in Oracle SQL 23.26.4: a follow-along lab
Release Update 23.26.4 of Oracle AI Database 26ai added four new pieces of SQL. Here they are as I teach them: what each is for, how hard it is, and 25 steps to type, each with the exact output my lab printed on 23.26.4.
SQL> SELECT ename, sal, BAR_CHART(sal/50) AS bar FROM emp ORDER BY sal; ENAME SAL BAR ---------- ---------- ---------- SMITH 800 JAMES 950 ADAMS 1100 WARD 1250 MARTIN 1250 MILLER 1300 TURNER 1500 ALLEN 1600 CLARK 2450 BLAKE 2850 JONES 2975 SCOTT 3000 FORD 3000 KING 5000 14 rows selected.
The four features at a glance
- SELECT * with other columns (beginner): put your own columns before or after
*. - BAR_CHART (beginner): draw a bar for each row, right in the query result.
- FETCH FIRST … FOR UPDATE SKIP LOCKED (advanced): let several sessions each take their own batch of rows.
- TUMBLE, HOP, CUMULATE, SESSIONS (advanced): group rows into time windows.
Beginners: do parts 1 and 2. After transactions and analytic functions: parts 3 and 4.
- 1. SELECT * beside other columnsBeginner
Purpose: add a calculated column next to every column, without typing each column out.
- 2. BAR_CHARTBeginner
Purpose: see the shape of your data in the result itself, with no Excel or BI tool.
- 3. FETCH FIRST with FOR UPDATE SKIP LOCKEDAdvanced
Purpose: let several sessions each lock their own batch of rows without waiting on one another, the job-queue pattern.
- 4. TUMBLE, HOP, CUMULATE and SESSIONSAdvanced
Purpose: group events into time buckets: per hour, overlapping, growing, or split into sessions.
Before you start: your lab
You need Oracle AI Database 26ai at release 23.26.4 or later. The free edition, Oracle AI Database 26ai Free, is enough; it is what I used. Connect as SCOTT, the sample schema, in the pluggable database FREEPDB1: sqlplus scott@freepdb1. If your database has no SCOTT, Oracle ships the script that creates it as rdbms/admin/scott.sql in the Oracle home; ask your trainer before running it.
Check your release
Every feature on this page needs 23.26.4. On an older release the steps fail with errors.
Type thisSELECT banner_full FROM v$version;You should see (23.26.4)BANNER_FULL ------------------------------------------------------------------------------------------------------------------------------------------------------ Oracle AI Database 26ai Free Release 23.26.4.0.0 - Develop, Learn, and Run for Free Version 23.26.4.0.0 1 row selected.
What to notice: the second line must say 23.26.4 or higher. If it says 23.26.3 or lower, update the database first.
I ran every step below on Oracle AI Database 26ai Free 23.26.4.0.0 on 30 November 2026, as SCOTT in FREEPDB1, with SET LINESIZE 150 and SET PAGESIZE 100. Each “You should see” box is that run’s output, unchanged. Tick each step as you finish it; your ticks stay in this browser only.
1. SELECT * beside other columns
Purpose: add a calculated column next to every column, without typing each column out.
Before 23.26.4, a bare * could not share the select list with anything else; you had to write the table’s name or alias in front, as in e.*. Now the star can stand anywhere in the list, and every item you write keeps its place.
Build a select list
Click the items in the order you want them, then read the columns you get back from EMP.
SELECT sal * 12 AS annual_sal, * FROM emp;
The columns you get- ANNUAL_SAL
- EMPNO
- ENAME
- JOB
- MGR
- HIREDATE
- SAL
- COMM
- DEPTNO
New in 23.26.4: your items stay where you put them and * fills in every EMP column at its place.
Put a calculated column in front of everything
Ask for the yearly salary, then every column of EMP, for department 10.
Type thisSELECT sal * 12 AS annual_sal, * FROM emp WHERE deptno = 10;You should see (23.26.4)ANNUAL_SAL EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- ---------- --------- ---------- ------------------ ---------- ---------- ---------- 29400 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 60000 7839 KING PRESIDENT 17-NOV-81 5000 10 15600 7934 MILLER CLERK 7782 23-JAN-82 1300 10 3 rows selected.What to notice: ANNUAL_SAL comes first because you wrote it first; the
*expanded to all eight EMP columns after it.Put * in the middle
Items can go before and after the star.
Type thisSELECT deptno, *, 'end' AS marker FROM dept;You should see (23.26.4)DEPTNO DEPTNO DNAME LOC MAR ---------- ---------- -------------- ------------- --- 10 10 ACCOUNTING NEW YORK end 20 20 RESEARCH DALLAS end 30 30 SALES CHICAGO end 40 40 OPERATIONS BOSTON end 4 rows selected.What to notice: DEPTNO appears twice, the one you listed and the one inside
*. Oracle allows it. If a program reads columns by name, give one of them an alias.Use it with a join
A bare star in a join expands every column of both tables.
Type thisSELECT e.ename, * FROM emp e JOIN dept d ON d.deptno = e.deptno WHERE e.empno = 7839;You should see (23.26.4)ENAME EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO DEPTNO DNAME LOC ---------- ---------- ---------- --------- ---------- ------------------ ---------- ---------- ---------- ---------- -------------- ------------- KING 7839 KING PRESIDENT 17-NOV-81 5000 10 10 ACCOUNTING NEW YORK 1 row selected.
What to notice: ENAME first, then all eight EMP columns, then all three DEPT columns. Write
e.*ord.*when you want one table only.
Try it yourself: the bonus column
Show every DEPT column followed by a column called CITY_CODE holding the first three letters of LOC.
Show one answer
SELECT *, SUBSTR(loc, 1, 3) AS city_code FROM dept;
Four rows: DEPTNO, DNAME, LOC, then CITY_CODE (NEW, DAL, CHI, BOS).
2. BAR_CHART: a bar for every row
Purpose: see the shape of your data in the result itself, with no Excel or BI tool.
BAR_CHART(value, maximum, minimum, width, symbol) returns a string of characters as long as the value is big. Only the value is required. If you give an argument, give every one before it too. The defaults are a maximum of 100, a minimum of 0 and a width of 10.
BAR_CHART playground
Change any argument. The bar is drawn the way 23.26.4 drew SCOTT’s salaries in steps 5 and 6; try a preset first.
BAR_CHART(2450, 5000, 0, 20, '#')
A bar for each salary
Scale the bar from 0 to 5000, 20 characters wide, drawn with #.
COLUMNjust sets the display width in SQL*Plus.Type thisCOLUMN chart FORMAT A20 SELECT ename, sal, BAR_CHART(sal, 5000, 0, 20, '#') AS chart FROM emp ORDER BY sal;
You should see (23.26.4)ENAME SAL CHART ---------- ---------- -------------------- SMITH 800 ### JAMES 950 #### ADAMS 1100 #### WARD 1250 ##### MARTIN 1250 ##### MILLER 1300 ##### TURNER 1500 ###### ALLEN 1600 ###### CLARK 2450 ########## BLAKE 2850 ########### JONES 2975 ############ SCOTT 3000 ############ FORD 3000 ############ KING 5000 #################### 14 rows selected.
What to notice: KING earns the maximum, 5000, so his bar is the full 20 characters. SMITH’s 800 is 3.2 characters, shown as 3.
Let BAR_CHART use its defaults
Give only the value. The default scale is 0 to 100 and the default width is 10 characters, so I divide by 50 to bring the salaries into that range.
Type thisCOLUMN bar FORMAT A10 SELECT ename, sal, BAR_CHART(sal/50) AS bar FROM emp ORDER BY sal;
You should see (23.26.4)ENAME SAL BAR ---------- ---------- ---------- SMITH 800 █▋ JAMES 950 █▉ ADAMS 1100 ██▎ WARD 1250 ██▌ MARTIN 1250 ██▌ MILLER 1300 ██▋ TURNER 1500 ███ ALLEN 1600 ███▎ CLARK 2450 ████▉ BLAKE 2850 █████▊ JONES 2975 ██████ SCOTT 3000 ██████ FORD 3000 ██████ KING 5000 ██████████ 14 rows selected.
What to notice: in a UTF-8 database the default symbol draws solid blocks, and part blocks for fractions: SMITH’s 1.6 characters is one block and a bit more than half.
Chart a GROUP BY
BAR_CHART takes any number, including an aggregate.
Type thisSELECT deptno, ROUND(AVG(sal)) AS avg_sal, BAR_CHART(AVG(sal), 5000, 0, 20, '#') AS chart FROM emp GROUP BY deptno ORDER BY deptno;You should see (23.26.4)DEPTNO AVG_SAL CHART ---------- ---------- -------------------- 10 2917 ############ 20 2175 ######### 30 1567 ###### 3 rows selected.Chart a TRUE or FALSE
Give it a condition and it draws one block for TRUE and a space for FALSE. The square brackets are only there so you can see the space.
Type thisSELECT ename, comm, '[' || BAR_CHART(comm IS NOT NULL) || ']' AS has_comm FROM emp WHERE deptno = 30;You should see (23.26.4)ENAME COMM HAS_COMM ---------- ---------- ------------ ALLEN 300 [█] WARD 500 [█] MARTIN 1400 [█] BLAKE [ ] TURNER 0 [█] JAMES [ ] 6 rows selected.
What to notice: TURNER’s commission is 0, which is NOT NULL, so he gets a block. BLAKE and JAMES have no commission at all.
The argument order trap
The second argument is the maximum, the third the minimum. Swap them on purpose.
Type thisCOLUMN swapped FORMAT A12 COLUMN right_order FORMAT A12 SELECT '[' || BAR_CHART(50, 0, 100, 10, '#') || ']' AS swapped, '[' || BAR_CHART(50, 100, 0, 10, '#') || ']' AS right_order FROM dual;
You should see (23.26.4)SWAPPED RIGHT_ORDER ------------ ------------ [] [##### ] 1 row selected.
What to notice: with the maximum below the minimum, BAR_CHART returns NULL: the empty brackets. No error, just nothing. Most students get this wrong the first time.
Try it yourself: chart the commission
For the salesmen, draw COMM on a 0 to 1500 scale, 15 characters wide, with *.
Show one answer
SELECT ename, comm, BAR_CHART(comm, 1500, 0, 15, '*') AS chart FROM emp WHERE job = 'SALESMAN' ORDER BY comm;
MARTIN’s 1400 is the longest bar, 14 characters. TURNER’s 0 gives a bar of spaces, which is not the same as NULL: a NULL value gives NULL.
3. FETCH FIRST with FOR UPDATE SKIP LOCKED
Purpose: let several sessions each lock their own batch of rows without waiting on one another. The classic job-queue pattern.
Picture a bank with several counters and one pile of token slips. Each clerk takes the next few slips that nobody else is holding. If clerk A is holding slips 1 to 10, clerk B should take 11 to 15, not stand and wait. That is what SKIP LOCKED does, and from 23.26.4 you can combine it with FETCH FIRST n ROWS ONLY to say how many.
You will need two SQL*Plus windows for this part, both connected as SCOTT. I mark each step with the window to type it in. Try the idea in the machine first.
Two windows, one queue
Thirty new orders. Lock some from window A, then see what window B gets with SKIP LOCKED and with NOWAIT.
- Locked by window A
- Locked by window B
- Done (committed)
- New
Window A
Window B
Window AMake a queue of 30 orders
Open two SQL*Plus windows, both connected as SCOTT. In window A, create the queue.
Type thisCREATE TABLE ru4_queue (order_id NUMBER PRIMARY KEY, status VARCHAR2(10)); INSERT INTO ru4_queue SELECT level, 'NEW' FROM dual CONNECT BY level <= 30; COMMIT;
You should see (23.26.4)Table created. 30 rows created. Commit complete.
Window ATake ten orders and keep them
Still in window A, lock the first ten new orders. This is the new part: a row limit and FOR UPDATE in one query. Do not commit.
Type thisSELECT order_id FROM ru4_queue WHERE status = 'NEW' ORDER BY order_id FETCH FIRST 10 ROWS ONLY FOR UPDATE;You should see (23.26.4)ORDER_ID ---------- 1 2 3 4 5 6 7 8 9 10 10 rows selected.What to notice: window A now holds row locks on orders 1 to 10 until it commits or rolls back.
Window BAsk for five orders, skipping locked ones
Switch to window B and ask for five.
Type thisSELECT order_id FROM ru4_queue WHERE status = 'NEW' ORDER BY order_id FETCH FIRST 5 ROWS ONLY FOR UPDATE SKIP LOCKED;You should see (23.26.4)ORDER_ID ---------- 11 12 13 14 15 5 rows selected.What to notice: B got 11 to 15 straight away. Orders 1 to 10 were skipped, and they did not count toward the five.
Window BNow ask with NOWAIT instead
In window B, release your five with ROLLBACK, then ask again with NOWAIT.
Type thisROLLBACK; SELECT order_id FROM ru4_queue WHERE status = 'NEW' ORDER BY order_id FETCH FIRST 5 ROWS ONLY FOR UPDATE NOWAIT;
You should see (23.26.4)Rollback complete. SELECT order_id FROM ru4_queue WHERE status = 'NEW' ORDER BY order_id FETCH FIRST 5 ROWS ONLY FOR UPDATE NOWAIT * ERROR at line 1: ORA-00054: Failed to acquire a lock (Type: "TX", Name: "Transaction", Description: "Lock held by a transaction to allow other transactions to wait for it") because it is currently held by another session. The resource being locked can be identified by 131086 ("usn<<16 | slot") and 559 ("sequence") ORA-40097: Failure to acquire row lock, currently held by transaction ID 2.14.559 Help: https://docs.oracle.com/error-help/db/ora-00054/What to notice: NOWAIT tried orders 1 to 5, found them locked by window A and failed at once. Without SKIP LOCKED or NOWAIT, window B would simply wait.
Window AFinish the work in window A
Back in window A, mark the ten orders done and commit. That releases the locks.
Type thisUPDATE ru4_queue SET status = 'DONE' WHERE order_id <= 10; COMMIT;
You should see (23.26.4)10 rows updated. Commit complete.
Window BAsk again from window B
Orders 1 to 10 are DONE now, so they no longer match
status = ’NEW’.Type thisSELECT order_id FROM ru4_queue WHERE status = 'NEW' ORDER BY order_id FETCH FIRST 5 ROWS ONLY FOR UPDATE SKIP LOCKED;You should see (23.26.4)ORDER_ID ---------- 11 12 13 14 15 5 rows selected.What to notice: 11 to 15 again, this time because they are the first new orders, not because anything is locked. Type
ROLLBACK;to release them.The two limits Oracle refuses
A row limit with FOR UPDATE must be a row count with ONLY. Try the other two forms on the same queue.
Type thisSELECT order_id FROM ru4_queue FETCH FIRST 10 PERCENT ROWS ONLY FOR UPDATE; SELECT order_id FROM ru4_queue ORDER BY status FETCH FIRST 5 ROWS WITH TIES FOR UPDATE;
You should see (23.26.4)SELECT order_id FROM ru4_queue FETCH FIRST 10 PERCENT ROWS ONLY FOR UPDATE * ERROR at line 1: ORA-01786: FOR UPDATE cannot be used with FETCH PERCENT ROWS Help: https://docs.oracle.com/error-help/db/ora-01786/ SELECT order_id FROM ru4_queue ORDER BY status FETCH FIRST 5 ROWS WITH TIES FOR UPDATE * ERROR at line 1: ORA-01786: FOR UPDATE cannot be used with FETCH ROWS WITH TIES Help: https://docs.oracle.com/error-help/db/ora-01786/
4. Time windows: TUMBLE, HOP, CUMULATE and SESSIONS
Purpose: group events into time buckets: orders per hour, overlapping or growing windows, and visits split into sessions.
These four are table functions: you use them in the FROM clause, where a table would go. Each returns your rows plus two new columns, WINDOW_START and WINDOW_END, and you group by those. The time column goes inside COLUMNS( ), and must be a plain DATE or TIMESTAMP column, not an expression.
See the windows
The white dots are the 30 orders of step 17, one every 7 minutes from 09:00. Each red bar is one window, with its count.
Make 30 orders, one every 7 minutes
Orders from 09:00 to 12:23 with an amount each. One window is enough for this feature.
Type thisCREATE TABLE ru4_orders ( order_id NUMBER PRIMARY KEY, status VARCHAR2(10) NOT NULL, amount NUMBER(8,2), order_time TIMESTAMP NOT NULL ); INSERT INTO ru4_orders SELECT level, 'NEW', 100 + MOD(level * 37, 900), TIMESTAMP '2026-11-30 09:00:00' + NUMTODSINTERVAL((level - 1) * 7, 'MINUTE') FROM dual CONNECT BY level <= 30; COMMIT;
You should see (23.26.4)Table created. 30 rows created. Commit complete.
Show times as hours and minutes
These SQL*Plus settings only change how the times are printed, so the windows fit on screen.
Type thisALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'HH24:MI'; COLUMN order_time FORMAT A10 COLUMN window_start FORMAT A12 COLUMN window_end FORMAT A10 SELECT order_id, order_time, amount FROM ru4_orders WHERE order_id <= 4 OR order_id >= 29 ORDER BY order_id;
You should see (23.26.4)Session altered. ORDER_ID ORDER_TIME AMOUNT ---------- ---------- ---------- 1 09:00 137 2 09:07 174 3 09:14 211 4 09:21 248 29 12:16 273 30 12:23 310 6 rows selected.Hourly totals with TUMBLE
TUMBLE takes the table, the time column in
COLUMNS( ), and the window size. It adds WINDOW_START and WINDOW_END to every row, so you group by them.Type thisSELECT window_start, window_end, COUNT(*) AS orders, SUM(amount) AS total FROM TUMBLE(ru4_orders, COLUMNS(order_time), INTERVAL '1' HOUR) GROUP BY window_start, window_end ORDER BY window_start;
You should see (23.26.4)WINDOW_START WINDOW_END ORDERS TOTAL ------------ ---------- ---------- ---------- 09:00 10:00 9 2565 10:00 11:00 9 5562 11:00 12:00 8 5660 12:00 13:00 4 1018 4 rows selected.
What to notice: 9 + 9 + 8 + 4 = 30. Every order is in exactly one window.
Check the edges
Look at three orders either side of 10:00.
Type thisSELECT order_id, order_time, window_start, window_end FROM TUMBLE(ru4_orders, COLUMNS(order_time), INTERVAL '1' HOUR) WHERE order_id BETWEEN 8 AND 10 ORDER BY order_id;
You should see (23.26.4)ORDER_ID ORDER_TIME WINDOW_START WINDOW_END ---------- ---------- ------------ ---------- 8 09:49 09:00 10:00 9 09:56 09:00 10:00 10 10:03 10:00 11:00 3 rows selected.What to notice: a window includes its start and excludes its end, so 09:56 is in the 09:00 window and 10:03 in the 10:00 one. An order at exactly 10:00 would go in the 10:00 window.
Overlapping windows with HOP
HOP takes the slide first, then the size: a new 1-hour window every 30 minutes.
Type thisSELECT window_start, window_end, COUNT(*) AS orders FROM HOP(ru4_orders, COLUMNS(order_time), INTERVAL '30' MINUTE, INTERVAL '1' HOUR) GROUP BY window_start, window_end ORDER BY window_start;
You should see (23.26.4)WINDOW_START WINDOW_END ORDERS ------------ ---------- ---------- 08:30 09:30 5 09:00 10:00 9 09:30 10:30 8 10:00 11:00 9 10:30 11:30 9 11:00 12:00 8 11:30 12:30 8 12:00 13:00 4 8 rows selected.
What to notice: the first window starts at 08:30, before the first order. Windows line up with the clock, not with your data. The counts add up to 60: every order is in two windows.
Growing windows with CUMULATE
CUMULATE takes the step, then the maximum size: windows that start together and grow by 30 minutes up to 2 hours.
Type thisSELECT window_start, window_end, COUNT(*) AS orders FROM CUMULATE(ru4_orders, COLUMNS(order_time), INTERVAL '30' MINUTE, INTERVAL '2' HOUR) GROUP BY window_start, window_end ORDER BY window_start, window_end;
You should see (23.26.4)WINDOW_START WINDOW_END ORDERS ------------ ---------- ---------- 08:00 09:30 5 08:00 10:00 9 10:00 10:30 4 10:00 11:00 9 10:00 11:30 13 10:00 12:00 17 12:00 12:30 4 12:00 13:00 4 12:00 13:30 4 12:00 14:00 4 10 rows selected.
What to notice: the windows start at 08:00, 10:00 and 12:00, the clock’s 2-hour marks. Inside each, the count only grows: 4, 9, 13, 17. That is a running total per 2-hour block.
Make a quiet gap
Delete four orders so there is a 35-minute pause between 10:03 and 10:38.
Type thisDELETE FROM ru4_orders WHERE order_id BETWEEN 11 AND 14; COMMIT;
You should see (23.26.4)4 rows deleted. Commit complete.
Split the day into sessions
SESSIONS takes one interval: the gap that ends a session.
Type thisSELECT window_start, window_end, COUNT(*) AS orders FROM SESSIONS(ru4_orders, COLUMNS(order_time), INTERVAL '20' MINUTE) GROUP BY window_start, window_end ORDER BY window_start;
You should see (23.26.4)WINDOW_START WINDOW_END ORDERS ------------ ---------- ---------- 09:00 10:23 10 10:38 12:43 16 2 rows selected.
What to notice: two sessions, of 10 and 16 orders. Each WINDOW_END is the last order plus the 20-minute gap: 10:03 + 20 = 10:23.
Try it yourself: orders per 90 minutes
Count the orders in 90-minute TUMBLE windows. Before you run it, guess where the first window starts.
Show one answer
SELECT window_start, window_end, COUNT(*) AS orders FROM TUMBLE(ru4_orders, COLUMNS(order_time), INTERVAL '90' MINUTE) GROUP BY window_start, window_end ORDER BY window_start;
Run it before step 23 or after, and compare: step 23 deletes four orders. Look at the first WINDOW_START and decide whether the window lined up with your first order or with the clock.
When you are done
Clean up
Drop the two tables the lab created. SCOTT’s own tables are not touched.
Type thisDROP TABLE ru4_queue PURGE; DROP TABLE ru4_orders PURGE;
You should see (23.26.4)Table dropped. Table dropped.
Teaching this in class
- Parts 1 and 2 fit in the first weeks, right after SELECT and functions. The BAR_CHART argument-order trap (step 9) is a good one to let students fall into first.
- Part 3 belongs after COMMIT, ROLLBACK and locking. Two windows side by side on the projector make the point better than any slide.
- Part 4 belongs after GROUP BY and analytic functions. Ask students to predict each window’s count from the machine before they run the query.
Test yourself
Ten questions, all from this lab. Pick an answer to see why.
Which of these runs on 23.26.4 but fails on older releases?
The answer: SELECT sal * 12, * FROM emp. A bare * beside other items is the new part. A table prefix (e.*) beside other items, and * on its own, always worked.
In SELECT deptno, *, ’end’ AS marker FROM dept, which column comes first?
The answer: DEPTNO, the one you listed. Items keep the place you gave them. That query returns DEPTNO, then DEPTNO, DNAME and LOC from the *, then MARKER.
BAR_CHART(sal, 5000, 0, 20, ’#’): what is the 5000?
The answer: The maximum. After the value come the maximum, then the minimum, the width and the symbol. Swap 5000 and 0 and you get NULL.
With no options, BAR_CHART(x) draws…
The answer: 0 to 100 in 10 characters. The default range is 0 to 100 and the default width 10, which is why it suits percentages. It never looks at the other rows.
Window A holds orders 1 to 10. Window B runs FETCH FIRST 5 ROWS ONLY FOR UPDATE SKIP LOCKED. What does B get?
The answer: Orders 11 to 15. Locked rows are skipped and do not count toward the 5, so B keeps looking until it has five unlocked rows. That is what my lab printed.
Same situation, but B uses NOWAIT instead of SKIP LOCKED. What happens?
The answer: ORA-00054. NOWAIT tries the first five rows, finds them locked and fails at once with ORA-00054. Without NOWAIT or SKIP LOCKED, B would wait.
Which of these is refused with FOR UPDATE?
The answer: FETCH FIRST 10 PERCENT ROWS ONLY. PERCENT and WITH TIES give ORA-01786. A row count with ONLY is allowed, and so is ORDER BY.
An order placed at exactly 10:00, with one-hour TUMBLE windows, goes into…
The answer: 10:00 to 11:00. A window includes its start and excludes its end. HOP and CUMULATE can put a row in more than one window; TUMBLE never does.
The first order was at 09:00. Why did the 2-hour CUMULATE window start at 08:00?
The answer: Windows line up with the clock, not with your first row. Window boundaries are fixed points of the clock: 2-hour windows start at 08:00, 10:00, 12:00. HOP’s first 1-hour window started at 08:30 for the same reason.
Which function splits rows into sessions after a quiet gap?
The answer: SESSIONS. SESSIONS takes one interval, the gap. In my lab a 35-minute pause split 26 orders into sessions of 10 and 16.
You got .
Questions students ask
What is new in Oracle SQL 23.26.4?
Release Update 23.26.4 of Oracle AI Database 26ai added four SQL features worth teaching: SELECT * beside other columns and expressions, the BAR_CHART function, FETCH FIRST n ROWS ONLY together with FOR UPDATE SKIP LOCKED, and the time-window table functions TUMBLE, HOP, CUMULATE and SESSIONS. It also added simplified SQL macros, which this lab leaves out.
Can I use SELECT * with other columns in Oracle?
From release 23.26.4, yes: SELECT sal * 12 AS annual_sal, * FROM emp works, and each item keeps the place you give it. Before that you needed a table prefix, as in SELECT e.*, sal * 12 FROM emp e, which still works.
What does BAR_CHART do in Oracle?
BAR_CHART(value, maximum, minimum, width, symbol) turns a number into a bar of characters in the query result. Only the value is required; the defaults are a range of 0 to 100 and a width of 10. In a UTF-8 database the default symbol draws solid block characters, with part blocks for fractions. If the maximum is below the minimum it returns NULL.
How do I use FOR UPDATE SKIP LOCKED with FETCH FIRST in Oracle?
Write the row limit, then the lock: SELECT order_id FROM orders WHERE status = ’NEW’ ORDER BY order_id FETCH FIRST 5 ROWS ONLY FOR UPDATE SKIP LOCKED. Rows locked by other sessions are skipped and do not count toward the 5. The limit must be a row count with ONLY: PERCENT and WITH TIES give ORA-01786.
What is the difference between TUMBLE, HOP, CUMULATE and SESSIONS?
TUMBLE makes fixed windows side by side. HOP makes fixed windows that start every slide interval, so they overlap. CUMULATE makes windows that start together and grow by a step up to a maximum size. SESSIONS starts a new window whenever the gap between rows reaches the interval you give.
Why does my HOP or CUMULATE window start before my first row?
Window boundaries are fixed points of the clock, not your first row. In my lab, with orders from 09:00, the first 1-hour HOP window ran from 08:30 and the 2-hour CUMULATE windows started at 08:00, 10:00 and 12:00.
Do I need a paid Oracle database to try these features?
No. Oracle AI Database 26ai Free, release 23.26.4 or later, has all four. I ran this lab on it with the SCOTT sample schema in the FREEPDB1 pluggable database.
Are these features in the 1Z0-171 SQL exam?
Oracle has not said, and an exam usually trails the newest release updates. We teach them because you will meet them at work; for the exam, the course follows Oracle’s published 1Z0-171 topics.
This lab is part of my Oracle SQL course, where every chapter runs like this: on a real Oracle database, on the classroom screen, with the mistakes left in.
Book a free demo classLearn SQL in this classroom
The Oracle SQL course runs for 90 classes of 2 hours: about 3 months on the fast track, or 6 months at the regular pace. In our classroom in Dharampeth, live online, or one-on-one, on Oracle AI Database 26ai, and mapped to Oracle’s SQL certification.
- Tell us what you have studied and what you want SQL for.
- We suggest where to begin, and tell you the next batch and the fee.
- You come to a free demo class and meet your trainer before you decide.
Visit us in Dharampeth
Unisoft Technologies, 2nd Floor, Prananand Building, West High Court Road, above Anand Bhandar, opposite Dress Code, Dharampeth, Nagpur 440010Thank you!
A counsellor will call you on about a demo class, the batch dates and the fee.
Message us on WhatsAppKeep learning
- Every Oracle release update we teachThe SQL course’s release roadmap, 23ai to 23.26.4
- DELETE vs TRUNCATE vs SHRINK SPACEThe high-water mark, from my Chapter 12 class
- Oracle Recycle Bin explainedWhy DROP TABLE does not free space
- Oracle SQL course in NagpurThe whole course, chapter by chapter
- Data Analyst courseSQL with Excel, Python and Power BI or Tableau
- All articlesThe Unisoft blog
Sources
- Release Update 23.26.4: Oracle AI Database New Features, 26ai.
- SELECT (the select list, and the row_limiting_clause with FOR UPDATE), BAR_CHART and Streaming Windowing Table Functions: Oracle AI Database SQL Language Reference, 26ai.
- Oracle error help: ORA-00054, ORA-01786.
- My lab run: Oracle AI Database 26ai Free 23.26.4.0.0, SCOTT in FREEPDB1, 30 November 2026.
Published 30 November 2026. If a later release update changes any of this, I will update the page.