ORA-00933: SQL command not properly ended

CodeRocker picture CodeRocker · Jan 27, 2011 · Viewed 7.5k times · Source

I'm getting this error in Oracle:

ORA-00933: SQL command not properly ended
for
DROP SEQUENCE IF EXISTS ownername.seq_name;

Why am I seeing this?

Answer

Vincent Malgrat picture Vincent Malgrat · Jan 27, 2011

the IF EXISTS clause doesn't exist in the DROP SEQUENCE command in Oracle.

You could use a PLSQL block to ignore the error:

SQL> DECLARE
  2     sequence_doesnt_exist EXCEPTION;
  3     PRAGMA EXCEPTION_INIT(sequence_doesnt_exist, -2289);
  4  BEGIN
  5     EXECUTE IMMEDIATE 'DROP SEQUENCE seq_name';
  6  EXCEPTION
  7     WHEN sequence_doesnt_exist THEN NULL;
  8  END;
  9  /

PL/SQL procedure successfully completed