Wrapper PL/SQL to shutdown immediate command

Hi,
I am working on 10g and 11g database. I want to check if anyone have created a wrapper script on top of command Shutdown immediate?
Reason: I want to use a pl/sql X that would give me an option to confirm to proceed the shutdown process. I was thinking about a wrapper pl/sql, as shutdown immediate could be dangerous when working on multiple prod database screens. I am using putty.
DB Versions: 10gR2 and 11gR2.
SQL> x
Do you want to shutdown down (y/n): y
Shutting down database
I have heard about the trigger -before-shutdown-trigger. Any thoughts would be helpful.
Cherrish Vaidiyan

Let's assume that the risk of error is high. How does prompting a user to enter "y" reduce that risk.
If I think I'm connected to db1 and I want to shut down db1 but I'm really connected to db2, I'm going to reflexively answer "y" to the prompt. It's very unlikely that the prompt is going to cause me to stop and consider what database I'm really connected to. The prompt is going to very quickly become white noise where I just reflexively type in "y" without thinking. Just like a user interface that pops up "Are you sure" dialog boxes all the time, the user will very quickly stop seeing the text of the message and whatever benefit you gained from the alerts will be lost.
On the other hand, there are lots of things that one can do to reduce the risk of error
- As has been suggested, you shouldn't be connecting AS SYSDBA unless you absolutely have to. If you happen to type "shutdown immediate" when you're connected to db2, you'll get a privileges error rather than shutting down the wrong database. Note that putting things like this into scripts can easily backfire and make errors more likely because you'll be tempted to have the script connect AS SYSDBA and eliminate the benefit of having your sessions normally run as a less privileged user. In fact, some of the best DBAs I've seen would have their login script issue a `SET TRANSACTION READ ONLY` when they connected just so that they had to make a conscious effort to allow their session to change data.
- There are all sorts of ways to make it obvious on the command line what database you're connected to. For example, I've seen plenty of DBAs that have their SQL*Plus command line changed to include the name of the database. People configure their telnet client (i.e. PuTTY) to have different background colors for different databases (i.e. red for production, yellow for test, green for development). That is generally much more effective than a prompt because it's far more likely that someone will get into the habit of checking (and double-checking and triple-checking) the background color, the database name on the prompt, etc. before issuing commands.
- General DBA practice would suggest that having two different sessions open at once where you're logged in AS SYSDBA in both is extremely problematic. It is extremely unlikely that you'd ever want that to happen-- a DBA should be doing one thing at a time and certainly only one thing that involves SYSDBA access.
Justin

Similar Messages

  • How to make "shutdown immediate"  command display information

    Hi All,
    i just shut down my database using "shutdown immeidate". it does not display any information and just stop there. i wait serveral minutes and it display nothing. i do not know that it is doing. so i just use "shutdown abort" to shutdown.
    does anyone know how to let "shutdown immeidate" to display some information to let me what it is doing now?
    thanks.

    Hi hutchins2,
    Thanks for posting, check the link below which seems to be the reason of our problem:
    Text-Based DAQmx Device Information Functions Return a NULL Result
    Eric NI

  • Database shutdown immediate - time calculation ?

    Hi,
    Good Day.
    did any one tried to calculate time the database would took to complete "shutdown immediate" command?
    hope to have a healthy discussion..
    Regards,
    Muhammad Ahmad

    Mohamed ELAzab wrote:
    Hello Jonathan Lewis,
    1-Please note that looking into the alert_sid.log is a good start as it will show if the smon process was dead according to the note:
    Shutdown Normal or Shutdown Immediate Hangs. SMON disabling TX Recovery [ID 1076161.6]
    I can see that that note is labelled: "Checked for relevance June 2009", but have you seen the garbage it suggests for temporary segments:
    <ul>
    Verify that temporary segments are decreasing
    To verify that the temporary segments are decreasing have an active session
    available in Server Manager or SQLPLUS during the SHUTDOWN IMMEDIATE. Issue the following
    query to ensure the database is not hanging, but is actually perform extent
    cleanup:
    SVRMGR/SQL> select count(block#) from fet$;
    COUNT(BLOC
    +7+
    SVRMGR/SQL> select count(block#) from uet$;
    COUNT(BLOC
    +402+
    </ul>
    For this to be true the temporary tablespace would have to be declared as dictionary managed, possibly even with contents = "PERMANENT" but it's so long since I've created a dictionary-managed TEMP that I can't be sure of the second point. I would be very cautious about trusting any document that started with such antiquated material - you can have no idea how much of its content might be (at best) deficient and (at worst) dangerously wrong.
    3-to know the transactions that will be rolled back please read the note:
    How to Check Why Shutdown Immediate Hangs? [ID 164504.1]
    Same type of problem - "Checked for relevance: Mar 2010", starts with:
    <ul>
    Start Server Manager (or SQL*Plus for 8i or higher)
    SVRMGRL> connect internal (or SYSDBA for 8i or higher)
    SVRMGRL> select * from x$ktuxe where ktuxecfl = 'DEAD';
    </ul>
    Although x$ktuxe will show you transaction states from the undo segment headers, and this might show you recursive (or other special case) transactions that do not appear in v$transaction, I wouldn't trust a note that is based on 7.3 technology to be an appropriate reference document.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • Shutdown immediate problem

    I'm trying to shutdown an Oracle9i database on Unix using SHUTDOWN IMMEDIATE but it just hangs.
    I checked the sessions in V$SESSION and noticed there were a few INACTIVE sessions. So I built a script that goes thru all the INACTIVE sessions and kills them.
    With all these sessions having status KILLED...when I try to run a SHUTDOWN IMMEDIATE, the database still hangs. I don't want to use SHUTDOWN ABORT.
    Does anyone have any information on what makes SHUTDOWN IMMEDIATE hang? Could there be some unix processes....or oracle processes?
    Thanks

    Dear All,
    I am also having some shutdown problem with the Oracle 10g on my Windows Server 2003 machine. My machine could not shutdown (means OS cannot completely shutdown the machine) even after i issued the "shutdown immediate" command.
    As what Jaafar said, we should kill the process from OS level. Can any of you explain more on this as I have no idea on how to do this? Which process should I kill after I issued the "Shutdown immediate" command?
    Thank you.
    best regards,
    Wnson

  • Shutdown immediate hanging

    I need to develop a scripts that shuts down all databases on a server. One of my databases sometimes hangs after issuing "shutdown immediate" command, and I want to handle this situation in my script. What I am thinking is to add "shutdown abort" in the script if "shutdown immediate" does not work. However, I do not know how to determine the database is hanging during shutdown immediate. Can you advise me on how to handle the shutdown immediate hanging problem in my shell script? Or is there better way to handle this in the script?
    Thank you very much for your help!

    As noted, if your shutdown immediate really hang because of rollback, then my method won't work either. The only different will be Oracle is going to do the rollback at next startup when doing instance recovery. In that case, the startup will appear to be hang.
    Check this metalink doc,
    What To Do and Not To Do When 'shutdown immediate' Hangs
    Doc ID: Note:375935.1
    There are cases where shutdown immediate hang because of bug.
    Shutdown Immediate Hangs
    Doc ID: Note:268884.1

  • If shutdown immediate hangs database waits one hour for shutdown abort

    we have schedules cold backup for our 11g database on redhat 5.3.
    there is a shell script written with shutdown immediate command.
    If database hangs during shutdown immediate database waits one hour for auto shutdown abort.
    but this happens once or twice in a month
    can we do this auto shutdown abort earlier than one hour ??

    user13376823 wrote:
    we have schedules cold backup for our 11g database on redhat 5.3.
    Since you're shutting down the database for cold backup so ensure it should be shutdown properly by shutdown or shutdown immediate cmd not by abort cmd.
    Consistent backup:-
    A backup taken when the database is mounted (but not open) after a normal shutdown. The checkpoint SCNs in the datafile headers match the header information in the control file. None of the datafiles has changes beyond its checkpoint. Consistent backups can be restored without recovery.
    http://docs.oracle.com/cd/B19306_01/backup.102/b14191/rcmconc1.htm#i1007616

  • Shutdown immediate hangs and HVM of a database

    Hi,
    I have following questions,
    1. What are the possible causes of SHUTDOWN IMMEDIATE command hangs
    and doesnt responds.
    2. What do u mean by High Water Mark(HVM) of a database. Because when we
    give SHUTDOWN IMMEDIATE command there is message in alert log file
    mentioning the HVM of a database.
    3.Also is there any relationship between shutdown process taking long time to
    shutdown a database and HVM of a database.
    4. If the database instance is up for a long time then does it take long time to
    shutdown a instance.
    Thanks,
    Girish A

    Hello,
    for 1.) view Metalink Note:375935.1. Maybe you even get an error: "SHUTDOWN: Waiting for active calls to complete". This has nothing to do with HWM but with already logged on sessions. Immediate means new connections are not able to log in, existing connetions are not disconnected at once.
    for 2.) the HWM is the highest point to which datafiles have been filled up. This is the value to which you are able to shrink (if you desire to). View Metalink Note:1034330.6 for message "License high water mark" in alert.log at shutdown ("highest number of concurrent users sessions").
    Greets,
    Hannibal

  • Exception caused by 'shutdown immediate'

    Hi,
    I am using a PL/SQL to delete or update tables.
    When Oracle is issued with 'Shutdown immediate' or 'Shutdown abort' or if Oracle is abruptly shutdown, I have to rollback the transactions. Although, I have not written a rollback command, Oracle automatically rolls back. This is the desired behaviour. This happens as desired in my machine. In Production environment, I believe the shutdown has thrown an exception. The logic I had entered in the exception block where we update an error table is visible in the Production environment. I could not recreate this exception in my system. I am not sure what exception Oracle throws on abrupt shutdown. So, I plan to write an exception block as a precaution. Do you please know what exceptions are possible ones if there is a abrupt shutdown.
    Regards,
    Raj

    > Do you please know what exceptions are possible ones if there is a abrupt shutdown.
    There is no exception thrown.
    SHUTDOWN ABORT is like disconnecting the power cord & no subsequent action occurs.

  • Put the query result of "EXECUTE IMMEDIATE" command in a local table

    Hi all.
    Is it possible to put the output of the "EXECUTE IMMEDIATE" command in a local table so that the ouput can be accessed through other procedures.
    Regards,
    Andila

    Hi Andila, well you could just make your dynamic sql statement an insert statement based on your select. See example below
    create column table test_table_1
    "COL1" nvarchar(10),
    "COL2" nvarchar(10)
    CREATE PROCEDURE INSERT_P() 
    LANGUAGE SQLSCRIPT AS 
      sql_string NVARCHAR(2000) := '';
    BEGIN 
      sql_string := 'insert into test_table_1 (select ''val1'', ''val2'' from dummy) ';
      EXECUTE IMMEDIATE (:sql_string); 
    END; 
    call insert_p();
    select * from test_table_1;
    However you may want to investigate other options instead of using dynamic SQL as this is not a recommended approach. Less optimized compared to standard sql.
    Peter

  • Shutdown immediate hangs

    SunOS 5.8
    Database version: 9.2.0.4.0
    Customer shutdown database every night for backup the datafiles to disk.
    For your information, 2 weeks ago customer moved datafiles to a new disk.
    The stoppscript has worked for a week.
    And after a week the database will not shutdown.
    We did a shutdown abort, and it works for a couple of days.
    Now it happend again. The database will not go down.
    Can't find any error messages!
    Any suggestions?
    # stoppscript
    . $HOME/.profile
    INSTANSER="BALA"
    echo
    echo "###########################################"
    echo "# Startar nedtagning av O R A C L E #"
    echo "###########################################"
    echo
    echo
    echo "####### Stoppar LISTENER #######"
    echo
    $ORACLE_HOME/bin/lsnrctl << EOF
    stop LISTENER
    exit
    EOF
    for i in $INSTANSER
    do
    ORACLE_SID=$i
    export ORACLE_SID
    echo
    echo "##### Stoppar instans - $ORACLE_SID #####"
    echo
    $ORACLE_HOME/bin/sqlplus /nolog << EOF
    connect / as sysdba
    shutdown immediate
    startup exclusive restrict
    shutdown
    exit
    EOF
    done
    echo
    echo "########################################"
    echo "# Slut nedtagning av O R A C L E #"
    echo "########################################"
    echo
    # Alert_log
    Tue Sep 5 01:16:48 2006
    Shutting down instance: further logons disabled
    Shutting down instance (immediate)
    License high water mark = 41
    Waiting for dispatcher 'D000' to shutdown
    All dispatchers and shared servers shutdown
    Tue Sep 5 01:16:55 2006
    ALTER DATABASE CLOSE NORMAL
    Tue Sep 5 01:16:55 2006
    SMON: disabling tx recovery
    SMON: disabling cache recovery
    Tue Sep 5 01:16:56 2006
    Shutting down archive processes
    Archiving is disabled
    Tue Sep 5 01:16:56 2006
    ARCH shutting down
    ARC0: Archival stopped
    Tue Sep 5 01:16:56 2006
    ARCH shutting down
    ARC1: Archival stopped
    Tue Sep 5 01:16:56 2006
    Thread 1 closed at log sequence 11287
    Successful close of redo thread 1.
    Tue Sep 5 01:16:56 2006
    Completed: ALTER DATABASE CLOSE NORMAL
    Tue Sep 5 01:16:56 2006
    ALTER DATABASE DISMOUNT
    Completed: ALTER DATABASE DISMOUNT
    ARCH: Archiving is disabled
    Shutting down archive processes
    Archiving is disabled
    Archive process shutdown avoided: 0 active
    Tue Sep 5 08:15:15 2006
    Shutting down instance (abort)

    I am having similar problem. My server has been up for around 100 days now. And I extensively use XML DB in my code. So, now the DOM memory failed for me, so, I am doing shutdown immediate in the hope that it might fix it ( or atleast start where it is hanging).
    Here is a snippet of my alert log file. Can you see where I am stuck at?
    Thu Sep 21 14:01:15 2006
    Process m001 died, see its trace file
    Thu Sep 21 14:01:15 2006
    ksvcreate: Process(m001) creation failed
    Thu Sep 21 14:28:38 2006
    Starting background process EMN0
    EMN0 started with pid=19, OS id=2396
    Thu Sep 21 14:28:38 2006
    Shutting down instance: further logons disabled
    Thu Sep 21 14:28:40 2006
    Stopping background process CJQ0
    Thu Sep 21 14:28:40 2006
    Stopping background process QMNC
    Thu Sep 21 14:28:42 2006
    Stopping background process MMNL
    Thu Sep 21 14:28:43 2006
    Stopping background process MMON
    Thu Sep 21 14:28:45 2006
    Shutting down instance (immediate)
    License high water mark = 23
    Thu Sep 21 14:28:45 2006
    Stopping Job queue slave processes
    Thu Sep 21 14:28:45 2006
    Job queue slave processes stopped
    All dispatchers and shared servers shutdown
    Thu Sep 21 14:28:55 2006
    ALTER DATABASE CLOSE NORMAL
    Thu Sep 21 14:28:55 2006
    SMON: disabling tx recovery
    SMON: disabling cache recovery
    Thu Sep 21 14:28:56 2006
    Shutting down archive processes
    Archiving is disabled
    Archive process shutdown avoided: 0 active
    Thread 1 closed at log sequence 411
    Successful close of redo thread 1
    Thu Sep 21 14:29:01 2006
    Completed: ALTER DATABASE CLOSE NORMAL
    Thu Sep 21 14:29:01 2006
    ALTER DATABASE DISMOUNT
    Completed: ALTER DATABASE DISMOUNT
    ARCH: Archival disabled due to shutdown: 1089
    Shutting down archive processes
    Archiving is disabled
    Archive process shutdown avoided: 0 active
    ARCH: Archival disabled due to shutdown: 1089
    Shutting down archive processes
    Archiving is disabled
    Archive process shutdown avoided: 0 active
    btw, This is my screen right now.
    U:\Rahul\sql>sqlplus sys as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Thu Sep 21 14:28:16 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Release 10.2.0.1.0 - Production
    SQL> sho sga
    Total System Global Area 436207616 bytes
    Fixed Size 1249440 bytes
    Variable Size 142610272 bytes
    Database Buffers 289406976 bytes
    Redo Buffers 2940928 bytes
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    Ok, when I am writing this post, I came back with this message.
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup
    ORACLE instance started.
    Total System Global Area 436207616 bytes
    Fixed Size 1249440 bytes
    Variable Size 142610272 bytes
    Database Buffers 289406976 bytes
    Redo Buffers 2940928 bytes
    Database mounted.
    Database opened.
    SQL>
    Still, any comments would be really appreciated.
    Thank you,
    Rahul.
    P.S - This is a 32 bit windows 2003 server. 10gR2.
    Message was edited by:
    rputtagunta

  • Job and shutdown immediate

    Hi,
    On our database there is too many job which running every 10 sec, and other each minute (but this job run for 10 minutes !).
    I would like to stop database, but how will work the command shutdown immediate ? It will wait the end of each job ? And for job which execute with 10 minutes of delay ?
    Nicolas.

    IMMEDIATE
    Does not wait for current calls to complete or users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    Joel Pérez
    http://www.oracle.com/technology/experts

  • Shutdown immediate won't work, Must abort to switch to SunCluster standby

    Customer has a Solaris Clusterware, The customer sees the semtimedop() system call returning EAGAIN when running "shutdown immediate" on their database on one cluster node. This is expected when the shared resource that the semaphore is protecting is unavailable. The shared resource is only being used by Oracle processes, so we need to know what the resource is and what the other processes are doing with it. MOS doc 760968.1 isn't helpful. A Solaris crash dump taken when the database shutdown problem was occurring showed no signs of an OS issue so database assistance is needed.
    We have tried to capture the following trace, but the trace is empty , and we 're stuck since then.
    SQL> alter session set events '10046 trace name context forever,level 12';
    SQL> alter session set events '10400 trace name context forever, level 1';
    SQL> shutdown immediate;

    don't you think it is about time you upgraded to something that hasn't been out of support since 2007 (almost 6 years ago...???). Hopefully you don't have any CC information stored in that db as there has not been any security updates since before it went to de-support.
    What I would like to know is how did you even get 9i to install on Solaris 10? IIRC, that is not even a supported OS/Oracle version configuration. As for your current problem,
    http://www.lmgtfy.com/?q=oracle+9i+suncluster+failover
    http://docs.oracle.com/cd/E19787-01/820-2574/gctbk/index.html

  • Maximum execute immediate commands in a procedure

    Hi All,
    I have written a procedure and my database size is 2 million records. i want to check for all special characters, as shown in my procedure. Is it possible to check for all special charachers like &39 to &255 checked within one single procedure. In that situation maximum immediate commands will be about 500.
    I am sending my procedure just for one of the charachters.
    CREATE or REPLACE PROCEDURE SPECIAL_YPOL1 (TABLENAME IN VARCHAR2,fieldname IN VARCHAR2)
    AUTHID CURRENT_USER
    IS
    TYPE YPOLCurTyp IS REF CURSOR;
    YPOL_cur      YPOLCurTyp;
    sqlSt      LONG;
    THEFIELD      VARCHAR2(250);
    BEGIN
    -- CHR(38)||39,
    SQLST:= 'SELECT ' || UPPER(fieldname) ||' FROM '|| UPPER(TABLENAME) ;
              SQLST:=SQLST ||' WHERE ' || UPPER(fieldname) ||' LIKE ''%'' || CHR(38)|| ''39,%''';
                   BEGIN
                        EXECUTE IMMEDIATE SQLST;
                        EXCEPTION WHEN OTHERS THEN
                        NULL;
                   END;
         OPEN YPOL_CUR FOR SQLST;
         LOOP
              FETCH YPOL_CUR INTO THEFIELD;
                   EXIT WHEN YPOL_cur%NOTFOUND OR YPOL_cur%NOTFOUND IS NULL;
                        SQLST:='UPDATE '||upper(UPPER(TABLENAME)) || ' SET '||UPPER(UPPER(fieldname)) ||' =REPLACE(' ||UPPER(fieldname)||','''||CHR(38) ||'39,'',CHR(39))';
                        SQLST:=SQLST||' WHERE '||UPPER(fieldname) ||' LIKE ''%'' ||CHR(38) || ''39,%''';
                   BEGIN
                        EXECUTE IMMEDIATE SQLST;
                        EXCEPTION
                             WHEN OTHERS THEN
                             DBMS_OUTPUT.PUT_LINE('ERROR2');
                   END;
         END LOOP;
    COMMIT;
    END SPECIAL_YPOL1;
    /

    You can use one more loop for that and catch all the special characters.
    SQL> ;
      1  begin
      2      for i in 38..255 loop
      3         dbms_output.put_line(chr(i));
      4      end loop;
      5* end;
    SQL> /
    +
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <
    =
    >
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    Q
    R
    S
    T
    U
    V
    W
    X
    Y
    Z
    ^
    `
    a
    b
    c
    d
    e
    f
    g
    h
    i
    j
    k
    l
    m
    n
    o
    p
    q
    r
    s
    t
    u
    v
    w
    x
    y
    z
    |
    ~
    PL/SQL procedure successfully completed.
    SQL> Cheers
    Sarma.

  • Shutdown immediate 10gR2 on Red hat enterprise

    hi
    we are using 10gR2,when i tried with sql>shutdown immediate
    nothing happened,seem that process hang.
    1. what should i do?
    2. need to know why it happend?
    any advice ......
    tq

    Hi,
    Just wait and see for some time, since usually it might take time to rollback the things of the uncommitted transactions, just from the pstack with process id what might have carried out @stack on system level or OS level.
    other wise oradebug the process stack we can able to trace out the things.
    - Pavan Kumar N
    Oracle 9i/10g - OCP
    http://www.oracleinternals.blogspot.com

  • Shutdown immediate taking time

    HI
    I m using oracle 10g release 2. on hpux itanium
    some of my database is taking longer time to shutdown more than 30 minutes. so usually i m doing
    startup force and than shutdown immediate... wat is the problem behind this and how can i resolve it plz suggest.

    A SHUTDOWN NORMAL will wait for sessions to disconnect. So, if you have application processes or users that do not disconnect, it will "hang". It is likely that this is causing your shutdown to delay. You could check the alert log file for messages about Oracle waiting for users to disconnect.
    A SHUTDOWN IMMEDIATE will kill active sessions, complete a rollback of transactions that are killed and then shutdown the database. If you are using a SHUTDOWN IMMEDIATE, this can take a long time if there are large active transactions (or many active transactions) that Oracle needs to rollback -- the rollback can take time. (Also, if there are very many connected sessions, Oracle will take time to disconnect all of them).
    A SHUTDOWN ABORT does a quick kill by shutting down the instance, without validating connected sessions. Rollback is automatically initiated by Oracle with the Instance Recovery at the STARTUP. The STARTUP can take slightly longer (in terms of seconds or a few minutes, generally) depending on the volume of Redo to be re-applied. Rollback is deferred to be executed after the OPEN.
    You could try a SHUTDOWN TRANSACTIONAL. However, this can still take a long time or "hang" if a user or application process (or multiple of them) has/have active transaction(s) and does/do not issue COMMITs.
    See the documentation on the SHUTDOWN command :
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12042.htm#i2699551
    Hemant K Chitale
    http://hemantoracledba.blogspot.com

Maybe you are looking for