Tuesday, November 13, 2018

Drop all objects of a schema-


Pre-requisite-  (Very Important)

We have to login in particular schema of which we want to drop all objects. Otherwise it will drop all the objects of SYSTEM and other important table and views.


begin

for i in 1..3 loop
for r in (select object_name, object_type from user_objects
          order by object_type, object_name)
  loop
  begin
    if (r.object_type = 'MINING MODEL') then
     execute immediate ' begin dbms_data_mining.drop_model('||''''||
       r.object_name||''''||'); end;';
    elsif (r.object_type = 'TABLE') then
      execute immediate 'drop table "'||r.object_name
                    ||'" cascade constraints purge';
    else
       execute immediate 'drop '||r.object_type||' "'||r.object_name||'"';
    end if;
    exception when others then null;
  end;
  end loop;
end loop;
end;
/

Sunday, November 11, 2018

What happens at backend when we fire alter database commit to switchover to physical standby-

Below Process will take place in background

1.) Notifies the primary database that a switchover is about to occur

2.) Disconnect all users from the primary database

3.) Generate a special redo record that signals the End of Redo (EOR)

4.) Converts the primary database into a standby database

5.) Once the standby database applies the final EOR record, guaranteeing that no data loss has been lost, converts the standby database into the primary database.


The new standby database (old primary) starts to receive the redo records and continues process until we switch back again. It is important to remember that both databases receive the EOR record so both databases know the next redo that will be received.