ROWNUM

Purpose

ROWNUM is a pseudo column that is assigned an incremental unique integer value for records of a table or subselects, beginning with 1.

Usage notes

Exasol implements ROWNUM adhering to the overall SQL semantics.

  • ROWNUM cannot be combined with other conditions in the WHERE clause. Anything you put into the WHERE clause of a statement filters input data. To avoid confusion and seemingly wrong results, we only allow ROWNUM in situations where the result is in line with Oracle's semantic.
  • ROWNUM cannot be used in combination with the PRIMARY KEY, UNIQUE, and FOREIGN KEY statements.
  • ROWNUM (in uppercase) is a reserved column name, which means that columns in tables or SELECT statements cannot be named ROWNUM, even when delimited with quotes as "ROWNUM". However, any variation in case will allow the name to be used. For example, the delimited name "rownum" is accepted, even if the system value SQL_IDENTIFIER_COMPARISON is set to IGNORE CASE.

Examples:
Copy
SELECT SALES_ID, ROWNUM 
FROM SALES 
WHERE ROWNUM <10;
SALES_ID ROWNUM
389577429 1
321740964 2
389577438 3
253762032 4
321740973 5
389577447 6
458941123 7
389577513 8
389577522 9