oracle create index if not exists

Solutions on MaxInterview for oracle create index if not exists by the best coders in the world

showing results for - "oracle create index if not exists"
Stefano
26 Jan 2019
1DECLARE
2    already_exists EXCEPTION;
3    columns_indexed EXCEPTION;
4    PRAGMA EXCEPTION_INIT ( already_exists, -955 );
5    PRAGMA EXCEPTION_INIT (columns_indexed, -1408);
6BEGIN
7    EXECUTE IMMEDIATE 'CREATE INDEX ord_customer_ix ON orders (customer_id)';
8    dbms_output.put_line('created');
9EXCEPTION
10    WHEN already_exists OR columns_indexed THEN
11        dbms_output.put_line('skipped');
12END;