Posted on August 15, 2008 by alexzeng
When the physical standby database lags far behind the primary database, using rman incremental backup is better than applying tons of archived logs. Here are steps.
Step1.Standby database: check the current scn
SQL> select current_scn from v$database;
CURRENT_SCN
—————————————-
788209520
Step2. Primary database: incremental backup from the scn.
run {
allocate channel dev_0 device type disk;
allocate channel dev_1 device type disk;
allocate channel dev_2 [...]
Filed under: Data Guard | Leave a Comment »
Posted on August 13, 2008 by alexzeng
Step1. check corrupted block file# and block#
SQL> SELECT * FROM V$DATABASE_BLOCK_CORRUPTION;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO
———- ———- ———- —————— ———
1 507 1 0 CORRUPT
Step2. recover corrupted block and then validate again
rman target /
blockrecover datafile 1 block 507;
–To recover many blocks, using
BLOCKRECOVER DATAFILE 2 [...]
Filed under: Backup and Recovery | Leave a Comment »
Posted on August 12, 2008 by alexzeng
1. Type of constraint
C (check constraint on a table)
P (primary key)
U (unique key)
R (referential integrity)
V (with check option, on a view)
O (with read only, on a view)
2.Statu of constraint
1) Enable Validate:
a) check current data. If invalidate, the constraint cannot be created or enabled. b) the constraint is enabled c) check new inserted or updated data. [...]
Filed under: Data Management | Leave a Comment »
Posted on August 8, 2008 by alexzeng
Method 1) Oracle connect to Sql server
Using Oracle Gateway in 11g, if the database version is 10g, patch 5965763 should be installed on it.
Step1: Install Oracle gateway at an existing Oracle 11g home or a new home, and configure listener, oracle gateway for Sql server initial file:
In our example, using new ORACLE_HOME /u01/app/oracle/product/11.1.0/db_1
1) [...]
Filed under: Configuration Management | Leave a Comment »
Posted on August 6, 2008 by alexzeng
Here is an example:
Table:
Create table t1(id number, hours date, total number);
merge into t1 a
using (select 200 id, to_date(‘2004-12-28 10′,’yyyy-mm-dd hh24′) hours from dual ) b
on(a.id=b.id and a.hours=b.hours)
when matched then
update set total=a.total+1
when not matched then
insert (a.id,a.hours,a.total) values(b.id,b.hours,1);
Note:
a. Statement after merge into and using should be table.
b. Statement after matched should be update statement; Statement after not [...]
Filed under: Data Management | Leave a Comment »
Posted on August 5, 2008 by alexzeng
create or replace trigger a_trigger
before delete on a
declare
username varchar2(20);
ipaddress varchar2(20);
sessionuser varchar2(20);
begin
SELECT sys_context(‘USERENV’,’OS_USER’) into username FROM dual;
SELECT sys_context(‘USERENV’,’IP_ADDRESS’) into ipaddress FROM dual;
SELECT sys_context(‘USERENV’,’SESSION_USER’) into sessionuser from dual;
insert a_delete_history (trigger_time,os_username,sess_username,ip_address) values (sysdate,username,sessionuser,ipaddress);
end a_trigger;
Filed under: Data Management | Leave a Comment »
Posted on August 4, 2008 by alexzeng
Sometimes we need to get to know which sqls do not use bind variables. Here we can see how to find it out by using procedures.
create table t1 as select sql_text from v$sqlarea;
alter table t1 add sql_text_wo_constants varchar2(1000);
create or replace function
remove_constants( p_query in varchar2 ) return varchar2
as
l_query long;
l_char varchar2(1 char);
l_in_quotes boolean [...]
Filed under: Performance Management | Leave a Comment »
Posted on August 4, 2008 by alexzeng
Scenario:
When we drop or truncate a large table, it is very slow sometimes.
Why slow?
1. When a truncate is issued, the checkpoint process does a complete scan (till 9204) of the buffer cache. All of the dirty buffers of the object in the buffer cache are written down to disk. All of the clean buffers [...]
Filed under: Data Management | 1 Comment »
Posted on August 1, 2008 by alexzeng
There are lots of methods to trace oracle sessions.
1. alter session set events ‘10046 trace name context forever,level 12′;
alter session set tracefile_identifier=’10046′;
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
Start trace:
alter session set events ‘10046 trace name context forever,level 12′;
Stop trace:
alter session set events [...]
Filed under: Performance Management | 1 Comment »