intro
Solve ORA-00933 in Oracle by removing trailing semicolons, unsupported clauses (ORDER BY, JOIN), and syntax errors. Learn common causes and step-by-step fixes.
The "ORA-00933: SQL Command Not Properly Ended" error is a common issue in SQL databases, especially in Oracle. It occurs when a query has an unexpected clause, a missing keyword, or extra characters at the end.
Learn how to troubleshoot and fix this error!
What Is “ORA-00933 Error: SQL Command Not Properly Ended”?
When you encounter the error “ORA-00933: SQL command not properly ended”, it usually means there is a syntax issue in your SQL statement (common in Oracle databases). The database is telling you the query had an unexpected clause or extra characters at the end.
That often happens in Oracle when using an inappropriate clause (e.g. an ORDER BY
in a subquery or a JOIN
in an UPDATE
) or even an extra semicolon in certain environments.
How to Fix ORA-00933 Error: SQL Command Not Properly Ended
Quick Solution: Inspect the end of your SQL statement and remove or fix any offending syntax. First, do not include a trailing semicolon when executing an Oracle query via JDBC or another client–Oracle will add it automatically.
Consider this example:
1
SELECT * FROM employees WHERE department_id = 10;
This will raise the following error:
1
Error report: SQL Error: ORA-00933: SQL command not properly ended
2
00933. 00000 - "SQL command not properly ended"
In the above example, removing the semicolon fixes the error in Oracle:
1
SELECT * FROM employees WHERE department_id = 10
Second, ensure you’re not using clauses where they don’t belong (like ORDER BY
inside a view definition or JOIN
in an Oracle DELETE
without proper syntax). Learn more in our guide on the order of execution in SQL.
Third, check for unsupported SQL syntax. Oracle’s SQL dialect has some differences from other databases. For instance, an UPDATE
statement in Oracle doesn’t directly support JOIN
syntax the way SQL Server or MySQL do. If you wrote something like UPDATE A JOIN B ON ...
in Oracle, it will throw ORA-00933. The solution is to rewrite the query using a subquery or the Oracle-specific MERGE
statement instead.
Deeper Explanation and Common Causes or Error ORA-00933
In Oracle, ORA-00933 (“SQL command not properly ended”) can be caused by a variety of issues in the SQL syntax. Common causes include:
1
UPDATE A
2
SET x = <value>
3
WHERE A.id IN (
4
SELECT B.id FROM B WHERE <condition>
5
);
This way, you avoid an unsupported join in the UPDATE.
Summary
Check your SQL statement for any extra punctuation or clauses that don't belong. Oracle expects a very specific syntax; even an innocuous extra keyword can trigger this error. In particular, the Oracle documentation advises to “correct the syntax by removing the inappropriate clauses”.
By carefully reviewing the SQL (especially the end of the statement and any complex clauses), you can pinpoint the issue. Remove any trailing semicolons (if executing via code), and restructure the query if you're using a clause that Oracle doesn't allow.
Once the query is properly formatted and only contains supported syntax, the error will be resolved and your SQL command will execute successfully.
To reduce these kinds of errors or troubleshoot them quickly, consider using a powerful Oracle database client like DbVisualizer. With features like autocomplete, error highlighting, and advanced debugging tools built right into its SQL editor, it makes handling the "ORA-00933: SQL Command Not Properly Ended" error—or any other error—much easier. Download it for free today!