Dropping account by itself while still connected?

I will connect as myself and then drop myself from the same session:

-sh-3.2$ sqlplus miladin/xxxxx

SQL*Plus: Release 11.1.0.6.0 – Production on Tue Jan 13 17:23:53 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 – 64bit Production
With the Partitioning, Real Application Clusters, Oracle Label Security, OLAP,
Data Mining and Real Application Testing options

SQL> drop user miladin;

User dropped.

How come??

Read more of this post

Supported Backup, Restore and Recovery Operations using Third Party Snapshot Technologies

I live in Florida and there are many hurricanes every year.. So disaster recovery is important topic for me.And there is constant battle between Unix/Linux team or Storage team ( Storage Farmers ) and DBA’s when comes to restoring and recovering.Some company split tasks.

Backup and restoring are part of a Unix/Linux team or farmers  and recovery is stritcly done by DBA..

Personally I preffer to be in charge of both but sometime you do not have a choice…

I remember that many times  during recovery we will run into issues related to fuzzy files .System admin folks took snapshot without placing database in BACKUP mode.And then finger pointing  starts..

The main reasons why Oracle requires putting the associated data files or database in BACKUP mode are

  • ensuring file header consistency prior to the backup and updating the file headers with the recovery start time
  • creating sufficient redo to recover from any fractured or inconsistent blocks
  • creating a “end backup” marker to demarcate the minimum recovery time to ensure database consistency after restoring and recovering the data files.

But here is good news:

Oracle will officially support the following operations assuming that the third party snapshot technology can meet the prerequisites listed in the next 2 sections.

Backup Operations

Full database snapshot without the database in backup mode

1 . If a point-in-time copy of the database is required, the snapshot must contain all the data files, control files and online redo logs.

2.  If full (i.e. zero data loss) recovery or point-in-time recovery is required, the snapshot must contain only the data files or have the ability to restore only the data files.

For detail information refer to  Metalink Note 604683.1 

Capturing binds.

Capturing bind information using v$sql_bind_capture, v$sql_bind_metadata

Starting with 10g view v$sql_bind_capture displays bind variable metadata and values for a SQL cursor .

Suppose to be faster than sql_trace or  event 10046 at level 4

Demo:

SQL> var test number

SQL> exec :test :=10

PL/SQL procedure successfully completed.
SQL> select * from scott.emp where deptno=:test;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
———- ———- ——— ———- ——— ———- ———- ———-
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

SQL>  alter system set  “_cursor_bind_capture_interval”=1;

System altered.
SQL> select * from v$sql_bind_metadata where bind_name = ‘TEST’;

ADDRESS            POSITION   DATATYPE MAX_LENGTH  ARRAY_LEN BIND_NAME
—————- ———- ———- ———- ———- ——————————
00000000FD78FA38          1          2         22          0 TEST
00000000FD34E3F0          1          2         22          0 TEST
00000000FD7CF7F0          1          2         22          0 TEST
SQL>  select sql_text from v$sql where child_address in (’00000000FD34E3F0′,’00000000FD7CF7F0′,’00000000FD78FA38′);

SQL_TEXT
———————————————————————————————————————————————————————–
select * from scott.emp where deptno=:test
SELECT :test test FROM DUAL
BEGIN :test :=10; END;
select sql_text,name,value_string,datatype_string
    from v$sql_bind_capture join v$sql using (hash_value)
    where sql_text like
      ‘%select * from scott.emp where deptno=:test%’;

SQL_TEXT                                           NAME                 VALUE_STRING    DATATYPE_STR WAS LAST_CAPT
————————————————– ——————– ————— ———— — ———
select * from scott.emp where deptno=:test         :TEST                10              NUMBER       YES 09-JAN-09

 Demo  for v$sql_bind_metadata

SQL> alter system flush shared_pool;

System altered.

SQL> var test number
SQL> set linesize 167
SQL> select * from v$sql_bind_metadata where bind_name = ‘TEST’;

no rows selected

Now trick using PRINT

SQL> print test

      TEST
———-
SQL> select * from v$sql_bind_metadata where bind_name = ‘TEST’;

ADDRESS                         POSITION   DATATYPE   MAX_LENGTH  ARRAY_LEN  BIND_NAME
—————-                    ———- ———- ———- ———- ——————————
00000000FD34E3F0              1                                   2         22             0                                             TEST

or directly from x$ table

SQL> select * from x$kksbv where KKSBVNNAM=’TEST’;

ADDR                   INDX    INST_ID KGLHDADR           POSITION   KKSCBNDT   KKSCBNDL   KKSCBNDA KKSBVNNAM
—————- ———- ———- —————- ———- ———- ———- ———- ——————————
00002AAAAC18A558        489          1 00000000FD34E3F0          1          2         22          0 TEST

SQL> select sql_text from v$sql where child_address=’00000000FD34E3F0′;

SQL_TEXT
——————————————-
SELECT :test test FROM DUAL

PRINT  use SELECT FROM DUAL …. 

Oracle recommends use of bind variables for your applications versus non-shared SQL. However too much binds can cause  library latch contention  (bug 3517658).

To check if there are many bind variables being used in system, the following query can be run:

select avg(bind_count) AVG_NUM_BINDS  from
(select sql_id, count(*) bind_count
from v$sql_bind_capture
where child_number = 0
group by sql_id);

But there is catch: Read more of this post

Change on firing order on before trigger and FK delete cascade in 11g

Order of execution for 10g :  Child trigger fire before master trigger.

Order of execution for 11g:   Master trigger fire before  Child.

According to Oracle  starting with version 8.1   they collect all  before statement triggers and fire before DML for all tables involved with delete with cascade.Order of execution is undefined .Same for multiple triggers on the same table.Starting with 11g we can guarantee execution order for triggers defined with the same timing  using FOLLOWS clause.

So all these changes on triggers in 11g introduced this behavior.Problem is if your application runs on 10g and it  is using triggers and fk with cascade delete and you are upgrading to 11g.Something to think before upgrade..

Read more of this post