Comprare Oracle Data Between two Schema

While browsing On internet Today i found some script that will help you to compare data between two schema in Oracle for those who don’t love to use tools you can Download them from :

Script Number One
Script Number Two

There are Serveral Tools Used for Comparing such as :

1-Open Source application for comparing two tables of data
2-TOAD FOR ORACLE
3-Oracle SQL DEVELOPER 
4-Oracle Enterprise Manager (OEM).
5-Compare any Two Database http://www.dbsolo.com/schema_comparison.html .
6-RedGate to Compare Data, schema , Database .


Thank you 
Osama Mustafa

Some Way To Active Oracle Trace

Reading to Oracle Documentation the trace is facility provides performance information on individual SQL statements. It generates the following statistics for each statement:

  • Parse, execute, and fetch counts
  • CPU and elapsed times
  • Physical reads and logical reads
  • Number of rows processed
  • Misses on the library cache
  • Username under which each parse occurred
  • Each commit and rollback

To enable Oracle Trace you can do the following :

 Option Number One :

alter session set sql_trace = true;

Disable it :

alter session set sql_trace = false;

Option Number two :

Activate
dbms_session.set_sql_trace (true);
Deactivate

dbms_session.set_sql_trace (false);

Option Number three:

Activate
dbms_support.start_trace (binds=>{true|false}, waits=>{true|false});
Deactivate

dbms_support.stop_trace;

Notice that package is not installed by default , Check
EVENT: 10046 “enable SQL statement tracing (including binds/waits)” [ID 21154.1]

There’s The most Common way to Trace your SQL and enable trace , there’s other way you can search on it via Google or Oracle Documentation , all you have to do is trying one of these options .

some Other Useful link :
1-Oracle Documentation 
2-Oracle traces description.
3-Enable Oracle Traces

Thank you
Osama

Oracle EBS Patch Tips

What We Mean By Patch ?

Is Program designed to fix some Bugs Or Particular problem .

types of file in patch

cxxxx.drv         the ‘c’ or copy driver
dxxxx.drv         the ‘d’ or ‘database’ driver
gxxxx.drv         the ‘g’ or ‘generate’ driver  -form rep chart
jxxxx.zip         jar file

Applying Patch On EBS ?

-Go to Patch Directory , Unzip .
-inside patch Directory , you find Patch.DRV
-After Run Apps-.evn run adpatch
-answer on the question .
-On Some where in the question , you will be asked to apply patch name which is .DRV

Note : You Need to Enable Maintenance Mode using adadmin .

You will find Topics in Details on my blog talking about how to use adadmin and Adpatch .

Thank you
Osama Mustafa

Oracle Default Users

When you are creating Database , By Default there’s Users Created In Installation Phase , Check Them :

SYS
The SYS user owns all base tables and user-accessable view of the data dictionary (Oracle configuration information). No Oracle user should ever alter (update, delete, or insert) any rows or schema objects conatained in the SYS schema, because such activity can compromise data integrety. The security administrator must keep strict control of this central account. 
 
SYSTEM
The SYSTEM user is used to create additional tables and views that display administrative information, and internal tables and views used by various Oracle options and tools. 
 
SYSMAN
The SYSMAN user represents the Enterprise Manager super admin account. This EM admin can create and modify other EM admin accounts as well as admin the database instance itself.
 
DBSNMP
The DBSNMP user is used by EM to monitor the database. EM uses this account to access performance stats about the database. The DBSNMP credentials sometimes referred to as the monitoring credentials. 
 
 
In addition to these users, a user can connect with diffrent levels of privileges, namely SYSDBA and SYSOPER. When you connect using “connect sys/passwd as sysdba” your connecting as the SYS user and requesting SYSDBA privs. Because the SYS user is the Oracle equivilent to the UNIX root user Oracle makes you specify the amount of control you have, which is why you’ll get an error if you try to connect without specifying the privs.
 
The big diffrence between SYSDBA and SYSOPER privs is that SYSDBA can do anything (just like root). The SYSOPER privs allow you just about the same amount of control but won’t allow you to look at user data. Both privs allow you to ALTER DATABASE, CREATE SPFILE, STARTUP or SHUTDOWN, ALTER DATABASE ARCHIVELOG, and includes RESTRICTED SESSION privs. However, only SYSDBA can CREATE or DROP DATABASE, and the ALTER DATABASE RECOVER options for SYSOPER are limited to complete recovery only. 
 
 
There’s Another Users you can find Them On This Link 
 
 
Thank you 
Osama mustafa

Find blocking sessions In Oracle

  You can query the gv$lock and gv$session views to locate a blocking session in RAC.

Miladin Modrakovic offers this script to detect and kill RAC blocking sessions, using  GV$Session and GV$Lock.

 CREATE OR REPLACE PROCEDURE kill_blocker
AS
   sqlstmt   VARCHAR2 (1000);
BEGIN
   FOR x IN (SELECT gvh.SID sessid, gvs.serial# serial,
                    gvh.inst_id instance_id
               FROM gv$lock gvh, gv$lock gvw, gv$session gvs
              WHERE (gvh.id1, gvh.id2) IN (SELECT id1, id2
                                             FROM gv$lock
                                            WHERE request = 0
                                           INTERSECT
                                           SELECT id1, id2
                                             FROM gv$lock
                                            WHERE lmode = 0)
                AND gvh.id1 = gvw.id1
                AND gvh.id2 = gvw.id2
                AND gvh.request = 0
                AND gvw.lmode = 0
                AND gvh.SID = gvs.SID
                AND gvh.inst_id = gvs.inst_id)
   LOOP
      sqlstmt :=
            ‘ALTER SYSTEM KILL SESSION ”’
         || x.sessid
         || ‘,’
         || x.serial
         || ‘,@’
         || x.instance_id
         || ””;
      DBMS_OUTPUT.put_line (sqlstmt);

      EXECUTE IMMEDIATE sqlstmt;
   END kill_blovk;
END TEST;
/         

when the script  will generate it will execute Alter session to kill This Session .

Some Useful Link
1-Erik Wramner

Thank you
Osama mustafa
 

 

Redhat virtualization (KVM)

I am So Proud Today to write this topic , after 14 Hours Of continuous working . I Enabled Virtualization On Redhat , Its was challenging to me ,  I feel for moment its impossible to enable it .

But After finishing KVM installation and see everything is working fine i knew its deserve every moments . I believe in what they say now ” Never Give Up ” . I posting this article today for the people who wants to learn something new. And if you face any problem you can contact me here, I Wrote this because there’s no much information about the package that you should install while you are working on Virtualization But Hope you will find this useful.

you can install the package from Redhat Media , some Package will Generate what called Package Dependency , You will start searching for missing Package on media with same name as appear to you . its waste of time , i will post under this topic the most important package that you need to install to avoid this error. 
Some Other Information you need to know To Check If KVM Support : 

Solution One Using :

/proc/cpuinfo , the output :


The flags to look out for are:

  • vmx — Intel VT-x, basic virtualization
  • svm — AMD SVM, basic virtualization
  • ept — Extended Page Tables, an Intel feature to make emulation of guest page tables faster.
  • vpid — VPID, an Intel feature to make expensive TLB flushes unnecessary when context switching between guests.
  • npt — AMD Nested Page Tables, similar to EPT.
  • tpr_shadow and flexpriority — Intel feature that reduces calls into the hypervisor when accessing the Task Priority Register, which helps when running certain types of SMP guests.
  • vnmi — Intel Virtual NMI feature which helps with certain sorts of interrupt events in guests.

Solution Two :

dmesg | less
 

The two messages to look out for are:

kvm: no hardware support and
kvm: disabled by bios

To load KVM:

Intel

modprobe kvm_intel 

 AMD :

modprobe kvm_amd
 
 
 


Package that you need to install (Sorted) :

 etherboot-zroms-kvm-5.4.4-10.el5.x86_64.rpm
 kmod-kvm-83-105.el5.x86_64.rpm
 celt051-0.5.1.3-0.el5.x86_64.rpm
 log4cpp-1.0-4.el5.x86_64.rpm
 qpixman-0.13.3-4.el5.x86_64.rpm
 qcairo-1.8.7.1-3.el5.x86_64.rpm
 qffmpeg-libs-0.4.9-0.15.20080908.el5.x86_64.rpm
 qspice-libs-0.3.0-39.el5.x86_64.rpm
 kvm-83-105.el5.x86_64.rpm
 cyrus-sasl-md5-2.1.22-5.el5.x86_64.rpm
 iscsi-initiator-utils-6.2.0.871-0.10.el5.x86_64.rpm
 bridge-utils-1.1-2.x86_64.rpm
 kvm-qemu-img-83-105.el5.x86_64.rpm
 gnome-python2-gnomekeyring-2.16.0-3.el5.x86_64.rpm
 gtk-vnc-0.3.8-3.el5.x86_64.rpm
 gtk-vnc-python-0.3.8-3.el5.x86_64.rpm
 xen-libs-3.0.3-94.el5.x86_64.rpm
 xen-devel-3.0.3-94.el5.x86_64.rpm
 libvirt-0.6.3-20.el5.x86_64.rpm
 virt-viewer-0.0.2-3.el5.x86_64.rpm
 libvirt-python-0.6.3-20.el5.x86_64.rpm
 python-virtinst-0.400.3-5.el5.noarch.rpm
 virt-manager-0.6.1-8.el5.x86_64.rpm

Some Other package you need to install for avoiding dependency error : 

xz-lib-***

xz-4.***

If you need to Run  convirt install the below package also (Sorted) :

kernel-xen-2.6.18-164.el5
xen-3.0.3-94.el5
gpg-pubkey-32a349c9-493c185a
socat-1.6.0.1-1.el5.rf
tunctl-1.5-2.el5
python-crypto-2.0.1-13.1.el5.kb.1
python-paramiko-1.7.4-1.el5
convirt-1.1-1.fedora 

 Thank you
Osama Mustafa

ORA-01502: index ‘%’ or partition of such index is in unusable state

To Solve this error you could use more than one solution :

Solution One :

declare
begin
   for index_rec in (select owner, index_name
                     from dba_INDEXES
                     where status = ‘UNUSABLE’)
   loop                    
      execute immediate ‘alter index ‘ || index_rec.owner || ‘.’ ||
          index_rec.index_name || ‘ rebuild’;
   end loop;
end;

Solution two:

10g and above :

alter system set skip_unusable_indexes=true;

 thank you
Osama mustafa 

Find which User are Running SQL Query

I will post this script here , and you can download it also :

SELECT 
SUBSTR(SS.USERNAME,1,8) USERNAME,
SS.OSUSER "USER",
AR.MODULE || ' @ ' || SS.machine CLIENT,
SS.PROCESS PID,
TO_CHAR(AR.LAST_LOAD_TIME, 'DD-Mon HH24:MM:SS') LOAD_TIME,
AR.DISK_READS DISK_READS,
AR.BUFFER_GETS BUFFER_GETS,
SUBSTR(SS.LOCKWAIT,1,10) LOCKWAIT,
W.EVENT EVENT,
SS.status,
AR.SQL_fullTEXT SQL
FROM V$SESSION_WAIT W,
V$SQLAREA AR,
V$SESSION SS,
v$timer T
WHERE SS.SQL_ADDRESS = AR.ADDRESS
AND SS.SQL_HASH_VALUE = AR.HASH_VALUE
AND SS.SID = w.SID (+)
AND ss.STATUS = 'ACTIVE'
AND W.EVENT != 'client message'
ORDER BY SS.LOCKWAIT ASC, SS.USERNAME, AR.DISK_READS DESC

To Download the Script Press Here

Thank you
Osama Mustafa

check character set in Oracle

Simple Topic just to people who asked before why NLS_CHARACTER SET Not appearing in my V$PARAMETER View :

Just Use two Below Query Depend on your version 

SQL> select value from nls_database_parameters where 
parameter = 'NLS_CHARACTERSET' ;
 
VALUE
----------------------------------------
AR8MSWIN1256
 
 
Check the National Character set :
 
SQL> select value from nls_database_parameters where 
parameter = 'NLS_NCHAR_CHARACTERSET' ; 

 Or you can Use :

SELECT value$ FROM sys.props$ WHERE name = ‘NLS_CHARACTERSET’ ;

Thank you
Osama Mustafa

Oracle Performance – Statspack

I mention before in my blog how to Generate AWR Reports But now How to Generate Statpack and how to use it !!!!


enable Statpack :

By default Statpack is disable to enable it do the following

1- Create tablespace with size at least 200MB
2-@?/rdbms/admin/spcreate

Disable it 

@?/rdbms/admin/spdrop
 
Statpack works on snapshot you can do the following with oracle snap shot :
 
Generate Snapshot : 

exec statspack.snap;
 
Or
 
exec statspack.snap(i_snap_level => 10, i_modify_parameter => 'true'); 

Levels Description :


Level 0 - This level captures general statistics, 
including rollback segment, row cache, SGA, system events, background
events, session events, system statistics, wait statistics, lock
statistics, and Latch information.

Level 5 - This level includes capturing high resource usage SQL Statements, along with all data captured by lower levels.

Level 6 - This level includes capturing SQL plan and SQL plan usage
information for high resource usage SQL Statements, along with all data
captured by lower levels.

Level 7 - This level captures segment level statistics, including
logical and physical reads, row lock, itl and buffer busy waits, along
with all data captured by lower levels.
 
Level 10 - This level includes capturing Child Latch statistics, along with all data captured by lower levels. 
 
Delete SnapShot 


@?/rdbms/admin/sppurge;
 
Check SnapShot on Database Level : 

col "Date/Time" format a30
select snap_id
, snap_level
, to_char(snap_time,'HH24:MI:SS DD-MM-YYYY') "Date/Time"
from stats$snapshot
, v$database
order by snap_id
/

 To Scheducle One Hour Generate Snapshot :

@?/rdbms/admin/spauto.sql
 
This script use DBMS_JOB to create new job . you can check them from view dba_jobs
 and to delete job "exec dbms_job.remove();"
 
 

Finally Generate statpack Reports :

 
 @?/rdbms/admin/spreport.sql