Oracle errors

ORA-00933: SQL command not properly ended

ORA-00933: SQL command not properly ended

Oracle reached text after what it considered the end of the statement. Common causes are a trailing semicolon in dynamic SQL, the keyword AS before a table alias, or a clause in the wrong place.

What it means

The parser decided the statement was complete, but more text followed. Oracle does not accept anything it cannot fit into the statement it has already recognised, so it stops with ORA-00933 at the first unexpected word.

Common causes

How to fix it

  1. Remove the trailing semicolon from SQL passed to drivers or EXECUTE IMMEDIATE (PL/SQL blocks keep their END;).
  2. Drop AS before table aliases.
  3. Replace non-Oracle syntax: FETCH FIRST n ROWS ONLY (12c and later) instead of LIMIT, MERGE or a correlated subquery instead of UPDATE … FROM.
  4. Look at the word right after the point where the statement should have ended.

Example

Table aliases take no AS in Oracle:

-- ORA-00933
SELECT e.name FROM employees AS e;

-- Works
SELECT e.name FROM employees e;

No semicolon inside dynamic SQL:

EXECUTE IMMEDIATE 'DELETE FROM tmp_orders';   -- not 'DELETE FROM tmp_orders;'

In SQLlightspeed

When a statement fails, SQLlightspeed’s error panel shows the error code with a plain-language explanation and a suggestion for what to do next, together with Oracle’s own message and a link to Oracle’s documentation — for this error and dozens of other common ones.

Related errors

ORA-00936ORA-00907ORA-00904 All Oracle errors →

Oracle documentation for ORA-00933. Oracle is a registered trademark of Oracle Corporation. SQLlightspeed is not affiliated with Oracle.