Is there something like "if not exist create sequence ..." in Oracle SQL?

Posted by Timo on Stack Overflow See other posts from Stack Overflow or by Timo
Published on 2010-04-11T18:26:21Z Indexed on 2010/04/11 18:33 UTC
Read the original article Hit count: 382

Filed under:
|
|

Very probably a noob question: For my application that uses an Oracle 8 DB, I am providing an SQL script to setup stuff like triggers, sequences etc., which can be copied and pasted into SQL*Plus. I would like the script to not stop with an error if a sequence that I am trying to create already exists. For a Trigger this can easily be done using "create or replace trigger ...", but for a sequence this does not work. Is there some alternative, like "if not exists mysequence then create sequence ..." (I tried this but it did not work :) )

Alternatively, if this is not possible, is there a way to do a "drop sequence mysequence" without SQL*Plus aborting the script if mysequence does not exist?

Thanks.

PS: I wish Oracle just had a simple Autoinc field type ... sigh.

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about sql