oracle drop index if exists

前端 未结 5 1622
渐次进展
渐次进展 2020-12-28 13:53

How do you drop an index only if it exists?

It seems simple but I did found anything on the net. The idea is to drop it only if it exists, because if not, I will hav

5条回答
  •  醉梦人生
    2020-12-28 14:11

    Don't check for existence. Try to drop, and capture the exception if necessary...

    DECLARE
       index_not_exists EXCEPTION;
       PRAGMA EXCEPTION_INIT (index_not_exists, -1418);
    BEGIN
       EXECUTE IMMEDIATE 'drop index foo';
    EXCEPTION
       WHEN index_not_exists
       THEN
          NULL;
    END;
    /
    

提交回复
热议问题