ORACLE

How to Fix Oracle ORA-00933 Error: SQL Command Not Properly Ended

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.

Tools used in the tutorial
Tool Description Link
Dbvisualizer DBVISUALIZER
TOP RATED DATABASE MANAGEMENT TOOL AND SQL CLIENT

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:

Copy
        
1 SELECT * FROM employees WHERE department_id = 10;

This will raise the following error:

Copy
        
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:

Copy
        
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:

  • Disallowed clause at the end: For example, adding an ORDER BY at the end of an INSERT statement or view definition. In Oracle, you cannot use ORDER BY when creating a view or inserting data (the sorting can only be applied when selecting). If your SQL ends with an ORDER BY in such contexts, remove it to resolve the error.
  • JOIN syntax issues: Using an INNER JOIN or any JOIN in an UPDATE or DELETE without the proper workaround. Oracle doesn’t support the UPDATE ... JOINsyntax that MySQL does. You must rewrite those as sub-selects. For example, instead of UPDATE A JOIN B ON A.id=B.id SET A.x=..., do:
Copy
        
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.

  • Trailing semicolon in client SQL: If you are executing SQL via code (JDBC, PHP, etc.), do not include the ; in the SQL string. Oracle treats the semicolon as the end-of-command when using its own tools, but an API call should send the statement without it. Having an extra semicolon can cause Oracle to see an empty second command, triggering ORA-00933. Removing the semicolon resolves the issue.
  • Mismatched quotes or string literals: A less obvious cause is a typo in string quoting. If a quote is left unpaired, part of your query might be read as string text when it’s not, causing a syntax error. For example, WHERE name = 'O'Connor' will break. In such cases Oracle might throw “not properly ended” or a related error. The fix is to escape quotes correctly (e.g., O''Connor for O'Connor).
  • Using non-Oracle syntax: Another scenario is using database-specific syntax that Oracle doesn’t recognize. For instance, writing LIMIT 10 at the end of a query (valid in MySQL/PostgreSQL) will cause ORA-00933 in Oracle. Oracle’s equivalent would be using ROWNUM or the FETCH FIRST 10 ROWS syntax in Oracle 12c+. Removing or replacing the unsupported clause will fix the error.

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!

Dbvis download link img
About the author
TheTable
TheTable

The Table by DbVisualizer is where we gather together to learn about and simplify the complexity of working with database technologies.

The Table Icon
Sign up to receive The Table's roundup
More from the table
Title Author Tags Length Published
title

How to Compare Datetimes in SQL: Multiple Approaches

author TheTable tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 5 min 2025-06-04
title

The Complete Guide to CONCAT in SQL Queries: Syntax, Examples, and Best Practices

author Leslie S. Gyamfi tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 7 min 2025-06-03
title

What Is a Database Catalog?

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 6 min 2025-05-27
title

A Complete Guide to NOT EXISTS in SQL

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 8 min 2025-05-12
title

SQL DROP TABLE IF EXISTS Statement: Complete Guide

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 6 min 2025-05-05
title

TRUNCATE vs DELETE: SQL Comparison of the Two Statements

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 9 min 2025-04-23
title

How to Extract the Year from a Date in SQL

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 5 min 2025-04-21
title

A Guide to the SQL Standard Deviation Functions

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 6 min 2025-04-15
title

SQL EXISTS: Syntax and Use Cases with Examples

author Leslie S. Gyamfi tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 6 min 2025-04-14
title

SQL TRUNCATE TABLE: A Complete Guide

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 6 min 2025-03-26

The content provided on dbvis.com/thetable, including but not limited to code and examples, is intended for educational and informational purposes only. We do not make any warranties or representations of any kind. Read more here.