Search notes:

ORA-00933: SQL command not properly ended

Trailing semicolons

Semicolons are typically used in SQL scripts to separate SQL statements from one another, but they don't technically belong to the SQL statement and cause the ORA-00933: SQL command not properly ended error in the following example:
create table tq84_test_tab(a number);

begin
--
-- Note the trailing semicolon in the insert statement:
--
   execute immediate '
      insert into tq84_test_tab values(42);
   ';
end;
/

drop table tq84_test_tab;
Sometimes, a trailing semicolon also raises the ORA-00922: missing or invalid option error message.

Missing semicolon

In PL/SQL, the semicolon is important. Because it is missing in the following anonymous PL/SQL block, it raises the ORA-00933 error:
declare
   cnt   number;
begin
   select
      count(*) into cnt
   from
      user_objects
     
   dbms_output.put_line('Number of objects is: ' || cnt);
end;
/

GROUP BY

This error might also be thrown if the alias of a column in a select statement's select list is copied down to the group by clause:
select
   sum(bytes),
   owner          object_owner
from
   dba_segments
group by
   owner          object_owner
;

UNION ALL combined with GROUP BY

An ORA-00933 is also thrown when appling an order by clause to the first query of a statement that combines two queries with union all:
create table tq84_ora_933(gr varchar2(1), val number(4)); 

begin
   insert into tq84_ora_933(gr, val) values ('A', 1000);
   insert into tq84_ora_933(gr, val) values ('B',  500);
   insert into tq84_ora_933(gr, val) values ('C', 1500);
   commit;
end;
/
 
select  gr    , val      from tq84_ora_933 order by val desc union all
select 'TOTAL', sum(val) from tq84_ora_933;

drop table tq84_ora_933;
If the order by clause is applied at the end of the statement, Oracle throws ORA-00904: invalid identifier.

See also

This error is also thrown when attempting to return the value of an identity column with the insert … returning into clause.
In 23c (with improved error messages), the statements shown on this page produce the error message ORA-03048: SQL reserved word … is not syntactically valid following … rather than an ORA-00933.
Other Oracle error messages

Index