Search code examples
oracle-databasestartup

I want a procedure to be executed when Oracle starts


When I startup my Oracle instance, is it possible to get Oracle to run some PL/SQL during the initialization?

I have tried to find something on the web but my searches have not been fruitful.

More specifically,

If I issue

$ sqlplus ....
startup mount;
alter database open;

Can I get it to then run a PL/SQL procedure?


Solution

  • You are looking for an AFTER STARTUP trigger.

    ref: https://docs.oracle.com/database/121/LNPLS/create_trigger.htm#LNPLS01374

    CREATE TRIGGER my_on_open_trigger
    AFTER STARTUP ON DATABASE
    BEGIN
         <<< DO SOMETHING >>>
    END my_on_open_trigger;
    /