
Showing posts with label Oracle. Show all posts

Quick reference link for Oracle database patching
- Written by Kokei's Blog
- Posted Oct 31, 2014 at 9:46 AM
Evaluating and rolling out the latest database patches is one of the most common tasks for database administrator. For Oracle products, you will constantly receive the notification from Oracle (at least)quarterly telling you that the patches you need to implement.However, they wont tell which patch you need for your database versions, and you have search through their slow Oracle support portal to the find patch you need.
To save time, normally I go directly to this document, Quick Reference to Patch Numbers for Database PSU, SPU(CPU), Bundle Patches and Patchsets (Doc ID 1454618.1), and in this document I can see all the patches that have been released for different versions of Oracle databases.
This Oracle document certainly worth saving in the bookmark -)


Copy Schema from one machine to another machine using EXP/IMP
- Written by Kokei's Blog
- Posted Jun 29, 2011 at 10:38 PM

Determine the environment variables for a running Oracle instance in Solaris and Linux
- Written by Kokei's Blog
- Posted Jun 2, 2011 at 1:54 AM

Space is not freed after removing the file in Unix
- Written by Kokei's Blog
- Posted May 19, 2011 at 12:34 AM

Though I've knew Oracle has a good learning tutorial named Oracle By Example for a long time, only until few days ago I realized they have a cool page called Oracle Learning Library which is more fruitful than OBE. This library provides an access to different learning learning information such as, tutorial, OBE and demo etc for different Oracle products and, above all, a good documents searching page. Like!
http://apex.oracle.com/pls/apex/f?p=44785:1:0::NO

Oracle 11g Enterprise Edition and Standard edition features comparison
- Written by Kokei's Blog
- Posted May 7, 2011 at 11:57 PM
-Flashback Table, Flashback Database, Flashback Transaction, Flashback Transaction Query.
-Client Side query cache, Query Results cache, PL/SQL Function Result cache
17. Oracle Diagnostic Pack(Requires extra license)
18. Oracle Tuning Pack(Requires extra license, also requires the Diagnostic Pack
19. Database Resource Manager
20. SQL Plan Management
21. Oracle OLAP(Requires extra license)
22. Oracle Data Mining(Requires extra license)
23. Bitmapped index, bitmapped join index, and bitmap plan conversions

adrci> show homes



One of the most common reason why index is not used is because columns are defined as nullable when, in fact, those columns should be not null.
Here is an example.
create table t( c1 number, c2 varchar2(4000));
create index t_idx on t(c1);
begin
for i in 1..10000 loop
insert into t values(i,'abc');
end loop;
end;
/
exec dbms_stats.gather_table_stats('TEST','T');
select c1 from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | 40000 | 18 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| T | 10000 | 40000 | 18 (0)| 00:00:01 |
--------------------------------------------------------------------------
This is because c1 is nullable (can be null) , so the optimizer cannot rely on the index as there might be missed rows .
Since the every row in c1 contains value(from 1 to 10000), column c1 should be defined as not null instead of null.
alter table t modify (c1 not null);
select c1 from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 3163761342
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | 40000 | 7 (0)| 00:00:01 |
| 1 | INDEX FAST FULL SCAN| T_IDX | 10000 | 40000 | 7 (0)| 00:00:01 |
------------------------------------------------------------------------------
After redefining the column c1 as not null, index t_idx is used and cost of this query is reduced from 18 to 7.

One of the features in Oralce I have been longing for is automatic dump and trace files housekeep. In Oracle 10g and before, DBA / System Admin have to write their own scripts and scheduled it to run periodically in order to remove those old dump and trace files.
In Oracle 11g, trace, dump and alert files in ADR are automatically purged by the MMON process. The retention period for the these files can be controlled via two attributes -- LONGP_POLICY abd SHORTP_POLICY.
To view the current ADR retention policy, you can run the following command
ADRCI>show control
ADRID SHORTP_POLICY LONGP_POLICY LAST_MOD_TIME LAST_AUTOPRG_TIME LAST_MANUPRG_TIME ADRDIR_VERSION ADRSCHM_VERSION ADRSCHMV_SUMMARY ADRALERT_VERSION CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
248536116 720 8760 2010-09-21 18:17:08.915859 +08:00 2011-02-15 00:20:57.784615 +08:00 1 2 65 1 2010-09-21 18:17:08.915859 +08:00
1 rows fetched
By default, LONGP_POLICY and SHORTP_POLICY are set to 8760 and 360 hours respectively.
To change the value of retention policy, use set control command
ADRCI> set control (SHORTP_POLICY = 240)
Note that files that are purged based on LONGP_POLICY includes the following:
-files in the alert directory
-files in the incident/incdir_
-files in the sweep directory
-files in the stage directory
-HM — files in the hm directory and metadata in the HM schema
And files that are purged based on SHORTP_POLICY are:
-files in the trace directory
-files in the cdump directory
-files in the trace/cdmp_
-files in the incpkg directory and metadata in the IPS schema

3. You must be using automatic undo management to use the flashback table feature.


Oracle Database 11g: Interactive Quick Reference...Your essential guide to Oracle 11g?
- Written by Kokei's Blog
- Posted Apr 19, 2011 at 5:06 PM
Hope that there will be improvement for the next release of this reference, just like SQL Developer.
