Informix

Expand all | Collapse all

database exclusive access

  • 1.  database exclusive access

    Posted Fri March 19, 2021 01:04 PM
    Hi,

    I am having trouble making changes to some databases, I use a procedure that searches through syssessions and terminates all connections.
    However I have noticed that some dirty reads sessions and also sometimes connections to sysmaster:sysdatabases remain.
    If I run database <db> exclusive on my connection I get an error??!!
    I would appreciate some help, as I have servers with multiple databases and putting the engine in single user mode is causing some problems.

    Thanks in advance,

    SP

    ------------------------------
    Sergio Peres
    AIRC
    Coimbra
    ------------------------------


  • 2.  RE: database exclusive access

    Posted Fri March 19, 2021 01:40 PM
    Do this in a single script:

    dbaccess sysmaster - <<EOF
    SET LOCK MODE TO WAIT;  -- infinite wait
    RENAME DATABASE mydatabase TO mydatabase_locked;
    EOF


    Voila! As soon as all locks are removed from 'mydatabase' the rename will execute and you can do whatever you need to do before renaming it back.

    ------------------------------
    Art S. Kagel, President and Principal Consultant
    ASK Database Management Corp.
    www.askdbmgt.com
    ------------------------------



  • 3.  RE: database exclusive access

    Posted 29 days ago
    Thanks for help Art, it works perfect.

    Best regards,

    SP

    ------------------------------
    Sergio Peres
    AIRC
    Coimbra
    ------------------------------