ORA-00933 means Oracle parsed a complete statement and then found more text that does not belong to it, such as a clause in the wrong place or syntax from another database. In Oracle AI Database 26ai the same mistakes are reported more precisely, with ORA-03048 or ORA-03049 messages that name the unexpected word and quote the text before it. Older releases report them as ORA-00933. Either way, the fix is the same: remove or move the extra text.
Reproduce the Error
Four statements with text Oracle does not accept where it appears:
Example:
create table demo_orders (order_id number, amount number); select order_id from demo_orders order by order_id limit 5; -- LIMIT is MySQL/PostgreSQL select o.order_id from demo_orders as o; -- AS before a table alias delete from demo_orders where order_id = 1 order by order_id; -- ORDER BY in a DELETE insert into demo_orders values (1, 10) (2, 20); -- two rows in one VALUES
Output (Oracle AI Database 26ai):
Table DEMO_ORDERS created.
Error starting at line : 2
In command -
select order_id from demo_orders order by order_id limit 5
Error at Command Line : 2 Column : 52
Error report -
SQL Error: ORA-03049: SQL keyword 'LIMIT' is not syntactically valid following
'...demo_orders order by order_id '
Error starting at line : 3
In command -
select o.order_id from demo_orders as o
Error at Command Line : 3 Column : 36
Error report -
SQL Error: ORA-03048: SQL reserved word 'AS' is not syntactically valid following
'...o.order_id from demo_orders '
Error starting at line : 4
In command -
delete from demo_orders where order_id = 1 order by order_id
Error at Command Line : 4 Column : 44
Error report -
SQL Error: ORA-03048: SQL reserved word 'ORDER' is not syntactically valid following
'...where order_id = 1 '
Error starting at line : 5
In command -
insert into demo_orders values (1, 10) (2, 20)
Error at Command Line : 5 Column : 40
Error report -
SQL Error: ORA-03048: SQL reserved word '(' is not syntactically valid following
'...demo_orders values (1, 10) '- LIMIT is MySQL and PostgreSQL syntax; Oracle uses FETCH FIRST.
- Oracle does not allow AS before a table alias, only before column aliases.
- DELETE has no ORDER BY clause.
- One VALUES clause inserts one row.
On releases before 26ai, each of these reports ORA-00933: SQL command not properly ended.
Fix: Write the Oracle Form
Example:
insert into demo_orders values (1, 10); insert into demo_orders values (2, 20); select order_id from demo_orders order by order_id fetch first 5 rows only; select o.order_id from demo_orders o; delete from demo_orders where order_id = 1;
Output:
1 row inserted.
1 row inserted.
ORDER_ID
___________
1
2
ORDER_ID
___________
1
2
1 row deleted.To insert several rows in one statement, use INSERT ALL, INSERT ... SELECT, or a VALUES list with each row in its own parentheses separated by commas.
Other Common Causes
- A statement copied from SQL Server or MySQL, with clauses such as TOP, LIMIT, or ON DUPLICATE KEY.
- Two statements run as one, without a semicolon or slash between them.
- A JOIN or WHERE condition followed by extra words, such as a misspelled keyword.
Related Guides
- How to Fix ORA-00923: FROM Keyword Not Found Where Expected in Oracle
- How to Use Multitable INSERT ALL in Oracle
Conclusion
ORA-00933, and its more precise successors ORA-03048 and ORA-03049 in Oracle AI Database 26ai, mean a statement has text Oracle does not expect after a complete clause. Read the word named in the message, then replace syntax from other databases with Oracle's: FETCH FIRST for LIMIT, no AS before table aliases, and one row per VALUES list.
