// Oracle error reference

ORA-00933: SQL command not properly ended

Oracle finished parsing a valid statement and found more text after it: a stray clause, a trailing semicolon passed through a driver, or syntax from another database.

Error code
ORA-00933
Category
Syntax and SQL statements
Error message
SQL command not properly ended

What it means

ORA-00933 means the statement was complete up to a point and what followed didn't fit. It often comes from syntax that works in other databases but not in Oracle, or from a semicolon sent to the database through JDBC, ODBC or EXECUTE IMMEDIATE, where Oracle doesn't accept it.

Newer releases give the position: unexpected keyword at or near keyword_value.

Common causes

  • A trailing ; in SQL sent through a driver or dynamic SQL.
  • Using AS before a table alias (FROM employees AS e); Oracle allows AS only for column aliases.
  • LIMIT or TOP (Oracle uses FETCH FIRST n ROWS ONLY from 12c).
  • An ORDER BY inside an INSERT ... SELECT subquery or a misplaced clause.
  • UPDATE ... FROM or DELETE ... JOIN syntax from SQL Server or MySQL.

How to fix it

  1. Drop the semicolon when sending a single SQL statement through a driver or EXECUTE IMMEDIATE.

  2. Write table aliases without AS.

    SELECT e.last_name FROM hr.employees e;
  3. Use Oracle's row-limiting clause.

    SELECT * FROM hr.employees ORDER BY salary DESC FETCH FIRST 10 ROWS ONLY;
  4. Rewrite joined updates with MERGE or a correlated subquery.

    MERGE INTO orders o
    USING customers c ON (c.id = o.customer_id)
    WHEN MATCHED THEN UPDATE SET o.region = c.region;

Related errors

More syntax and sql statements errors

The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.

// fewer errors, faster fixes

Work on Oracle in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Oracle and the other databases you use.