Msg 3702, Level 16, State 3, Line 2 Cannot drop database “DataBaseName” because it is currently in use.

Try to drop a SQL database, but get following errors:

USE Master;
GO
DROP DATABASE dbTEST;
GO
Msg 3702, Level 16, State 4, Line 1
Cannot drop database "dbTEST" because it is currently in use.

SOLUTION

Kill the blocking sessions, or set database in SINGER_USER mode with “Rollback Immediate” option to kill  and rollback the transactions.

USE [master]
GO
ALTER DATABASE dbTEST SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
USE [master]
GO
DROP DATABASE dbTEST;
GO

After this, check both data files and log files are cleaned up as well.

How to Upgrade Oracle Enterprise Manager 13c Release 4

How to Upgrade Oracle Management Agents Using Agent Gold Images

This post demonstrates how to upgrade Oracle management agents by using agent gold images. Also provides two ways of upgrading agents. The first one is by using OEM GUI , and the second method is by using EM CLI.

Contents

Subscribe to get access

Read more of this content when you subscribe today.

dbms_spm.drop_sql_plan_baseline Fails With ‘ORA-14552: Cannot Perform A DDL, Commit Or Rollback Inside A Query Or DML

SYMPTOM

Drop a sql execution plan baseline with following errors:

SQL> select dbms_spm.drop_sql_plan_baseline(sql_handle=>    -
                       'SQL_89d3699974845bdb') from dual;
select dbms_spm.drop_sql_plan_baseline(sql_handle=>        -
                       'SQL_89d3699974845bdb') from dual
*
ERROR at line 1:
ORA-14552: cannot perform a DDL,commit or rollback inside 
           a query or DML
ORA-06512: at "SYS.DBMS_SPM", line 1210
ORA-06512: at "SYS.DBMS_SPM", line 1200
ORA-06512: at line 1

dbms_spm.drop_sql_plan_baseline updates dictionary tables. So you should not use it in a query.

SOLUTION

SQL> exec :xx :=dbms_spm.drop_sql_plan_baseline(sql_handle=>   -
                                   'SQL_89d3699974845bdb');

PL/SQL procedure successfully completed.

SQL> select :xx from dual;

:XX
----------
1

SQL> print :xx

XX
----------
1
Drop all sql execution plan baselines.
SQL> set serveroutput on
SQL> declare
     v_count pls_integer;
     v_sql_handle varchar2(50);
     cursor c1 is
     select sql_handle from dba_sql_plan_baselines
         where sql_handle like 'SQL_%';
     begin
        open c1 ;
        loop
            fetch c1 into v_sql_handle;
            exit when c1%notfound;
            v_count := dbms_spm.drop_sql_plan_baseline( 
                             sql_handle=>v_sql_handle );
           dbms_output.put_line(v_count);
      end loop;
  end;

 /
1
1
..
.
PL/SQL procedure successfully completed.

SQL> select count(*) from dba_sql_plan_baselines;

    COUNT(*)
 ----------
         0

How to Download and Deploy OEM Plug-Ins in Offline Mode