2)Sqlservercentral -
A Microsoft SQL Server community of DBAs, developers and SQL Server users
Welcome to my space. Find posts on useful quick fixes , technology tips, short stories and recipes.
|
The simplest way to remove Oracle is to run the Oracle installer:
Start > Programs > Oracle Installation Products > Universal Installer
Whilst the Oracle installer removes many components there are a number of things that it leaves behind. In order to completely remove all traces of Oracle the following additional steps will need to be taken:
OracleOraHome90TNSListener' and 'OracleServiceORACLE'. However there may be others depending on your installation. Look for any services with names starting with 'Oracle'.HKEY_LOCAL_MACHINE
\SOFTWARE
\ORACLE
HKEY_LOCAL_MACHINE
\SYSTEM
\CurrentControlSet
\Services
\EventLog
\Application
\Oracle.oracleHKEY_CURRENT_USER\SOFTWARE\ORACLE, this registry entry may be created by some Oracle utilities. If it exists then delete it. C:\Oracle"C:\Program Files\Oracle" C:\Documents and Settings\All Users\Start Menu\Programs\Oracle - OraHome90"
CREATE OR REPLACE PROCEDURE debugpkg (name IN VARCHAR2)
IS
cur INTEGER := DBMS_SQL.OPEN_CURSOR;
abc INTEGER;
BEGIN
DBMS_SQL.PARSE (cur,
'ALTER PACKAGE ' || name || ' COMPILE DEBUG',
DBMS_SQL.NATIVE);
abc := DBMS_SQL.EXECUTE (cur);
DBMS_SQL.CLOSE_CURSOR (cur);
END;
/
Oracle database maintains dynamic performance view V$BUFFER_POOL_STATISTICS with overall buffer usage statistics. This view maintains the following counts every time a data block is accessed either from the block buffers or from the disk:
NAME – Name of the buffer pool
PHYSICAL_READS – Number of physical reads
DB_BLOCK_GETS – Number of reads for INSERT, UPDATE and DELETE
CONSISTENT_GETS – Number of reads for SELECTDB_BLOCK_GETS + CONSISTENT_GETS = Total Number of reads
Based on above statistics we can calculate the percentage of data blocks being accessed from the memory to that of the disk (block buffer hit ratio). The following SQL statement will return the block buffer hit ratio:
SELECT NAME, 100 – round ((PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS))*100,2) HitRatio
FROM V$BUFFER_POOL_STATISTICS;A hit ratio of 95% or greater is considered to be a good hit ratio for OLTP systems. The hit ratio for DSS (Decision Support System) may vary depending on the database load. A lower hit ratio means Oracle is performing more disk IO on the server. In such a situation, you can increase the size of database block buffers to increase the database performance. You may have to increase the physical memory on the server if the server starts swapping after increasing block buffers.
alter session set tracefile_identifier = my_session;
SQL> oradebug setmypid
SQL> oradebug tracefile_name
Oradebug
The oradebug utility falls into the “hidden” classification of utilities due to the lack of available documentation. The utility is invoked directly from SQL*Plus beginning in version 8.1.5 and Server Manager in releases prior to that. The utility can trace a user session as well as perform many other, more global, database tracing functions.
oradebug requires the SYSDBA privilege to execute (connect internal on older Oracle versions). The list of oradebug options can be viewed by typing oradebug help at the SQL*Plus prompt:
If you want to give permission to a V$ view you must give it like below
SQL> grant select on v_$session to scott;
Grant succeeded.
CONNECT HR/your_password
@$ORACLE_HOME/rdbms/admin/utlxplan.sql
Table created.
CREATE TABLE plan_table
(
statement_id VARCHAR2(30),
timestamp DATE,
remarks VARCHAR2(80),
operation VARCHAR2(30),
options VARCHAR2(30),
object_node VARCHAR2(128),
object_owner VARCHAR2(30),
object_name VARCHAR2(30),
object_instance NUMBER,
object_type VARCHAR2(30),
optimizer VARCHAR2(255),
search_columns NUMBER,
id NUMBER,
parent_id NUMBER,
position NUMBER,
other LONG
)
** If you want an output table with a different name
RENAME PLAN_TABLE TO my_plan_table;
** Next, you can run the following script to get a list
of the steps that Oracle will perform in order to execute
your query:
set echo on
delete from plan_table
where statement_id = 'MINE';
commit;
COL operation FORMAT A30
COL options FORMAT A15
COL object_name FORMAT A20
EXPLAIN PLAN set statement_id = 'MINE' for
/* ------ Your SQL here ------*/
select * from scott.salgrade
/*----------------------------*/
/
set echo off
select operation, options, object_name
from plan_table
where statement_id = 'MINE'
start with id = 0
connect by prior id=parent_id
and prior statement_id = statement_id;
set echo on
** Displaying PLAN_TABLE Output withprocedure
DBMS_XPLAN.DISPLAY
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
SELECT PLAN_TABLE_OUTPUT
FROM TABLE
(DBMS_XPLAN.DISPLAY('MY_PLAN_TABLE', 'st1','TYPICAL'));
To learn more:Tutorial
SELECT
'EXECUTE DBMS_SHARED_POOL.KEEP('''||name||''');'
FROM v$db_object_cache
WHERE type='PACKAGE';
SELECT DISTINCT
'EXECUTE DBMS_SHARED_POOL.KEEP('''||name||''');'
FROM user_source
WHERE type='PACKAGE';
SELECT DISTINCT
'EXECUTE DBMS_SHARED_POOL.KEEP('''||object_name||''');'
FROM user_objects
WHERE object_type='PACKAGE';
select table
space_name, ceil(sum(bytes) / 1024 / 1024) "MB"
from dba_extents
where owner like '&user_id'
group by tablespace_name
order by tablespace_name;
6) Show table name, number of rows, block, empty blocks, avg row length
select table_name, num_rows, blocks, empty_blocks, avg_row_len
from dba_tables where
owner = 'SCOTT';
7)To see if any space is being wasted in the index
SELECT (DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100
“Wasted Space”
FROM index_stats
WHERE name = ‘EMPLOYEE_LAST_NAME_IDX’;
8)To calculate the Data Dictionary Cache hit ratio
SELECT 1 - (SUM(getmisses)/SUM(gets))
"Data Dictionary Hit Ratio"
FROM v$rowcache;
9)To determine the current size of the Shared Pool
SELECT pool, sum(bytes) "SIZE"
FROM v$sgastat
WHERE pool = ’shared pool’
GROUP BY pool;
10)Calculating the Database Buffer Cache hit ratio using
V$SYSSTAT
11)To calculate hit ratios for each of the individual
Buffer Pools
SELECT name "Buffer Pool",
1-(physical_reads / (db_block_gets + consistent_gets))
"Buffer Pool Hit Ratio" FROM v$buffer_pool_statistics
ORDER BY name;
12)To determine which tables are cached
SELECT owner, table_name
FROM dba_tables
WHERE LTRIM(cache) = ’Y’;
13)To calculate a Redo Log Buffer Retry Ratio
SELECT retries.value/entries.value
"Redo Log Buffer Retry Ratio"
FROM v$sysstat retries, v$sysstat entries
WHERE retries.name='redo buffer allocation retries'
AND entries.name='redo entries';
14)Checkpoint activity shown in V$SYSTEM_EVENT
select event,total_waits,average_wait from v$system_event
where event like '%check%' or event like '%log file switch%';
15)Checkpoint activity shown in V$SYSSTAT
select name,value from v$sysstat where name
like '%background checkpoint%';
16) Redo Log activity shown in V$SYSTEM_EVENT
select EVENT , TOTAL_WAITS ,AVERAGE_WAIT
from v$system_event
where event='log file parallel write'
or event='log file switch completion';
17)V$LOCK to Monitor Lock Contention
SELECT s.username,
DECODE(l.type,'TM','TABLE LOCK','TX','ROW LOCK', NULL) "LOCK LEVEL",
o.owner, o.object_name, o.object_type
FROM v$session s, v$lock l, dba_objects o
WHERE s.sid = l.sid
AND o.object_id = l.id1
AND s.username IS NOT NULL;
18) Identify the application user that is blocking other users
SELECT s.username
FROM dba_blockers db, v$session s
WHERE db.holding_session = s.sid;