Thursday, 29 December 2011

Warm wishes for New Year 2012

Hi All,

Before the dawn reaches the dusk, before the verticals meets horizons, let us together welcome a New Year of warmth, prosperity and growth.

May the yer 2012 brings all greats, loads of love, happiness, and ample of opportunities of growth and survival.



SbhOracle would enter into its second year. 2011 has been a great year of establishment, reachability and credibility. And yes, it made a mark in alot more interactions in techworld.

Happy New year in Advance!!

Love you all,

Saurabh

Saturday, 24 December 2011

My publication at RMOUG SQL> Update


 Hi Guyzz,

Finally I made my publication into Winter issue of SQL>Update, the quartely journal of RMOUG. Thanks to Peggy King and Pat Van Buskirk for the great work and support in the process. Really it looks as an achievement to share the cover page with Tom Kyte  (Ask Tom)

 





 

 

 

 

 

 

 

 

 

My article reads about Inheritance in Oracle. As one of my earlier post talks about the abstract, the paper show the implementation of object model with a sample case study and forecasts it as an upcoming data model. Surely, the object model comfortably fits into OOPs based application requirements and offers better integration too.

You can find the complete story of the paper from the below link

Inheritance in Oracle by Saurabh Gupta (SQL Update Winter11 Issue RMOUG)

Do post your commets and feedback/suggestions. See you RMOUG again in Spring Issue.

Bye for now

Saurabh

 

Saturday, 17 December 2011

Sangam11 pics

Here I come with the pics from Sangam11

[gallery link="file" columns="1"]

Enjoy

Sunday, 11 December 2011

AIOUG Sangam 11

Hi Guyzzz

Just back from AIOUG Sangam11. Wonderful effort, event, sessions and most important grrat stage to share with some great names. Arup Nanda, Murali Vallath, Kuassi Mensah and many more. Kudos to the arrangement and and event management too.



The Day 1 (9th Dec) started off with registration. Was glad to see our bags and great material. Saw Murali at the doorstep and the day started off.

Murali addressed the session and thanked the event management team and introduced Arup to kick off the session. Arup Nanda 'The LONGTIME DBA' was the Show Stopper of the whole event. And he should be !!

Rich Niemiec started off with a session on Rolta. He showed us some pics of Oracle Corp...was amazed to be the part of it.





 

 

 

 

 

 



Arup started off with a session on Profiler in PL/SQL. Great sessions, great views and great information. Kuassi Mensah delivered a nice session on Oracle Net security. Murali too gave a presentation on RAC subject, but couldn't catch up match as I have no background. Hemant came up with the day to day challenges of a DBA, their role and expectations. Fabulous !!

Day 2 (10th Dec) again saw a long session from Arup until Lunch. Superb stamina and grasp !! Got to know some new concepts on Cache fusion, DBA best practices, and introduced the logic behind Exdata. I could see the roadmap of DBA to DMA (Database Machine Administrator). Again a good one!!

Meanwhile I got introduced to Arup Nanda with a handshake and told him about myself. Told him about my online works and he asked me to get in touch for SELECT journal too. Nice chat time !!

Later I attended session by Hemant on Partitioning. Though it was an elementary one but enough to fill up 1 hour session. The next session by Prabhakar Gongloor was another masterpiece where he showed some screendumps of Oracle 12C. I believe we would be only of those few ones who could see it within 2 months of the version release. I could see him hiding something by saying its 'Special Technique' through which EM can connect to DB even if it is down (as far as I could understand).

As I referred one of my colleague for the seminar, I received a coupon worth INR500, redeemable on the same day against the books at the counter. I got one copy of Oracle XML DB.

The conference ended with photo sessions. I too got few with Arup, Bryn, Rich and Mensah. Soon I would publish on my blog. Received a Tshirt from OTN too.

Next year, it would be in August, 2012...I will be happy to volunteer the event and would surely like to see myself at the stage right there :)

Once again, Thanks Oracle, Thanks AIOUG !!

By for now

Saurabh

Friday, 25 November 2011

Register for Sangam 2011 at AIOUG



Don't miss chance to meet ACEs and some great Oracle DBA and Developer sessions.

Sangam 2011.

See you all there !!

Thursday, 17 November 2011

Create a table with only scale specification for a column

Hi All,

Just came across a peculiar way of specifying only the column scale and not its precision, so thought of sharing with all. It looks pretty simple but could be a handy tip for table designs.

Scenario: Create a table CONT_EMPS where Salary column must store values upto 2 places of decimals (i.e. scale is 2). Here, note that no precision has been specified for the Salary column. Lets see how to do it.

SQL> CREATE TABLE CONT_EMPS
2 (EMPID NUMBER,
3 EMPNAME VARCHAR2(256),
4 SAL NUMBER(*,2))
5 /
Table created.


SQL> DESC CONT_EMPS
Name         Null?    Type
------------ -------- ----------------------------
EMPID                 NUMBER
EMPNAME               VARCHAR2(256)
SAL                   NUMBER(38,2)


When I specify '*' in place of precision, Oracle treats it as the maximum precision allowed for the column. Additionally, this convention doesn't applies to PL/SQL data type declaration.
 
Bye for now.
Saurabh

Related articles

Sunday, 6 November 2011

PL/Scope and PL/SQL Hierarchical Profiler in Oracle 11g

Hello world,

Ever since the release of Oracle 11gR2 in 2009 under the theme "Consolidate. Compress. Control", its new features have always been the talk of the conferences and meetings. But besides the compression, control and other development features, there were several other features which have got less weightage. I shall present my walkthrough experience in the below link (which has been published by Exforsys).

PL/Scope and DBMS_HPROF

Hope you enjoy reading the complete story and post your feedback and comments.

Thanks, bye

Saurabh


Saturday, 5 November 2011

Enable Encryption for SecureFiles

Last week, I was trying to enable ENCRYPTION property for Oracle 11g Secure File. But I couldn’t find sufficient information on the web. However, I have tried it now and would like to demonstrate on my blog.

Suppose I have a table EMPLOYEES where employees image (BLOB) has to be loaded into the database. You want to compress it and encrypt it as per AES192 encryption standard.

 Let us see how to do it. 

1. Compression can be easily enabled for the BLOB as below

ALTER TABLE EMPLOYEES
MODIFY LOB (IMAGE)
(
COMPRESS HIGH
)
/

Table altered.


2. Enabling the encryption feature for the IMAGE column in EMPLOYEES table

The TDE is an encryption system which encrypts the columns value with a confidential key. An encrypted key can hold multiple encrypted columns of same table. There exists second level of security where the column keys are again encrypted with database’s master key. But note that none of the keys are stored in database. They reside within an Oracle wallet. An encryption wallet has to be set as an external security module before enabling the feature for the LOB column.

Step 1: Create a Folder C:\ExternalSecurity\Wallets\ on the Oracle database server to store the Transparent Data Encryption (TDE) wallet.



Step 2: Edit the SQLNET.ora file at \\ORACLE_HOME\NETWORK\ADMIN location on the server. Include the ENCRYPTION_WALLET_LOCATION to indicate the location of the TDE wallet.

ENCRYPTION_WALLET_LOCATION=
(SOURCE=(METHOD=FILE)
(METHOD_DATA= (DIRECTORY= C:\ExternalSecurity\Wallets)
)
)




Step 3: Open the command prompt on the server machine to reload the server

Reload the Listener using RELOAD command




Step 4: Now login as DBA

Set the encryption key along with its password

SQL> ALTER system SET ENCRYPTION KEY IDENTIFIED BY "wallet";

System altered.


The ALTER SYSTEM command above keeps the wallet open until the database is up. If the database is down and restarted subsequently, the wallet has to be explicitly opened.

The error message raised below is not an error since the wallet gets automatically opened while setting

SQL> ALTER system SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet";
ALTER system SET ENCRYPTION WALLET OPEN IDENTIFIED BY "wallet"
*
ERROR at line 1:
ORA-28354: wallet already open


Step 5: Login as SCOTT user

Enter user-name: SCOTT/TIGER
SQL> ALTER TABLE EMPLOYEES
2 MODIFY
3 (
4 IMAGE ENCRYPT USING 'AES192'
5 );

Table altered.

SQL> SELECT *
2 FROM user_encrypted_columns;

TABLE_NAME COLUMN_NAME ENCRYPTION_ALG SAL INTEGRITY_AL
---------- -------------- ----------------------------- --- ------------
EMPLOYEES IMAGE AES 192 bits key YES SHA-1


Step 6: Verify the server wallet location. Check the ENCRYPTED WALLET LOCATION directory. You can find the ewallet.p12 filer created.



Note that the table carrying encrypted column(s) cannot participate in conventional export or import process. But data pump rescues the situation by supporting encrypted exports and imports.

Tuesday, 25 October 2011

Happy Diwali to all

Dear All,
I wish you all a very happy, safe, cracking, sparkling and colourful Diwali.  Have a great year ahead !!!

 



[caption id="attachment_268" align="alignleft" width="111" caption="India breaks away"]India breaks away[/caption]


 

 

 

 

Indian cricket has already gifted the Diwali gift with cracking clean sweep over England :)

 
 

 

Monday, 24 October 2011

Protect your database with VPD

Hi All,

Database security is an important aspect of database management and administration. Several database security solutions have been designed to prevent database from corruption, hacking threats, and unauthorized data access.

 Fine Grained Access Control (FGAC) is one of the security approaches which allow the logical and virtual partition of a database. In a multi user database environment, it becomes cumbersome activity to segregate schema and thus the data, based on user roles. Therefore, a security policy was required which can apply row level security and allows the current user to access only authorized data. For example, in an EMPLOYEE database, all managers can access only Managerial data, all HRs can view only HR related data and so on.

FGAC is also known as Virtual Private Database. It is because fine grained access can only be achieved after the database has been ‘virtually privatized’ for a user.

Thanks to Exforsys for publishing the paper. Read the complete story in the below link

Implement VPD in your database

Do post your comments/queries/feedback.

Saurabh

Thursday, 20 October 2011

Result Caching feature in Oracle 11g

Caching has always been the pick of the programmers world. These days applications formulate and maintain different strategy for Cache Manager. Database presents an efficient cache manager which is capable of caching the SQL query results, PL/SQL functions results and client OCI result cache.

In earlier versions of Oracle, caching mechanism was limited up to architectural concepts, but Oracle 11g makes it a programmer’s tool to explicitly govern the application performance.

My obligations to Exforsys to publish my write up on result cache feature in Oracle 11g

Read Result Cache in Oracle 11g

I 'll be back with some more new findings.

Bye, SBH

Tuesday, 18 October 2011

PLSQL_OPTIMIZE_LEVEL: The optimization strategy of Oracle

Oracle initialization parameter PLSQL_OPTIMIZE_LEVEL

The parameter was introduced in Oracle 10g to decide the level of optimization applicable for a program unit during compilation. The optimization during compilation means the removal of dead code, code movements to optimize iterative constructs, inline the calls if required, and choosing the best philosophy to optimally compile the program.

It is set by the DBA at system, session and object level. It is the object compilation parameter which is retained by the object library unit. It can be queried in USER_PLSQL_OBJECT_SETTINGS view for a given object.

Prior to 11g release, the parameter could accommodate only three valid values i.e. 0, 1, and 2. Oracle 11g introduced an additional optimization level 3. By default, the parameter value is 2. The compiler’s effort is directly proportional to the parameter value i.e. more the value, more the compiler’s effort.

It can be set using ALTER [SYSTEM | SESSON] command as shown below

/*To view the current parameter setting*/

Conn / as SYSDBA
Connected.

SQL> show parameter plsql_optimize_level

NAME TYPE VALUE
------------------------------------ ----------- -----------------
plsql_optimize_level integer 2

/*Modify the setting for the current session*/
ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 1
/

Session altered.

The description for each value is as below

Case 1: PLSQL_OPTIMIZE_LEVEL = 0

This level represents ‘No Optimization’ mode of the compiler. The compiler only maintains the code evaluation order and executes it without any efforts on code optimization.

Let us write a small program and compare the same with other optimization levels also

Scenario: In your application, you have to give insert a delay of approx 1 second during some user operations. You create a program which runs a large loop to delay the control transfer.

Conn / as sysdba
Connected.


ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 0;

Session altered.

DECLARE
L_START_TIME NUMBER;
L_END_TIME NUMBER;
A NUMBER; B NUMBER; C NUMBER;
BEGIN
L_START_TIME := DBMS_UTILITY.GET_TIME();
FOR I IN 1..1000000000
LOOP
A := 1;
B := 1;
C := A+1;
END LOOP;
L_END_TIME := DBMS_UTILITY.GET_TIME();
DBMS_OUTPUT.PUT_LINE('Execution time:'||TO_CHAR(L_END_TIME - L_START_TIME));
END;
/

Execution time:19294

PL/SQL procedure successfully completed.

Case 2: PLSQL_OPTIMIZE_LEVEL = 1

This level represents ‘Elementary and eliminative Optimization’ level by maintaining the same code order. The compiler optimizes the code by eliminating the code of irrelevant logic.

We shall re execute the previous PL/SQL block and check the difference.

Conn / as sysdba
Connected.


ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 1;

Session altered.

DECLARE
L_START_TIME NUMBER;
L_END_TIME NUMBER;
A NUMBER; B NUMBER; C NUMBER;
BEGIN
L_START_TIME := DBMS_UTILITY.GET_TIME();
FOR I IN 1..1000000000
LOOP
A := 1;
B := 1;
C := A+1;
END LOOP;
L_END_TIME := DBMS_UTILITY.GET_TIME();
DBMS_OUTPUT.PUT_LINE('Execution time:'||TO_CHAR(L_END_TIME - L_START_TIME));
END;
/

Execution time:7112

PL/SQL procedure successfully completed.

Note that the execution time has reduced by 60% during this optimization level.

Case 3: PLSQL_OPTIMIZE_LEVEL = 2

This is the standard level of optimization where the compiler intelligently does the code refactoring and uses advanced optimization techniques to modify the code structure in order to achieve the best.

Re executing the previous PL/SQL block to compare the ‘Execution time’ results.

Conn / as sysdba
Connected.


ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 2;

Session altered.

DECLARE
L_START_TIME NUMBER;
L_END_TIME NUMBER;
A NUMBER; B NUMBER; C NUMBER;
BEGIN
L_START_TIME := DBMS_UTILITY.GET_TIME();
FOR I IN 1..1000000000
LOOP
A := 1;
B := 1;
C := A+1;
END LOOP;
L_END_TIME := DBMS_UTILITY.GET_TIME();
DBMS_OUTPUT.PUT_LINE('Execution time:'||TO_CHAR(L_END_TIME - L_START_TIME));
END;
/

Execution time:0

PL/SQL procedure successfully completed.

Just observe the incredible intelligence of the PL/SQL compiler. The complete code has been re-structured. Analytically, the code inside the FOR loop is not relevant to the loop. So it has been moved outside the loop and now, the loop is completely ignored by the compiler. Therefore, the execution time comes out to be zero.

Case 4: PLSQL_OPTIMIZE_LEVEL = 3

This is the latest optimization level introduced in Oracle 11g. It is a sort of ‘Forced’ optimization level, which Oracle terms as ‘High Priority’ optimization. The code optimizer does the code refactoring and automatically inlines all program calls in the program unit.

Conn / as sysdba
Connected.


ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 3;

Session altered.

As mentioned earlier, the parameter is treated as the object compilation factors. Hence it is stored in the object library unit and can be queried in
[ALL | DBA | USER]_PLSQL_OBJECT_SETTINGS.

Refer Oracle 11g Documentation on the topic

Friday, 14 October 2011

My RMOUG abstract (Inheritance in Oracle)


Duke, the Java Mascot, in the waving pose. Duk...

 




Inheritance in Oracle: Exploring the Descendents
"The Abstract Object model of database is an under implemented and commercially unexplored flavor of database. In the late 1980s, relational model of Oracle faced several deficiencies, which forced the evolution of Object model. Undoubtedly, relational model did all well for flat data storage, maintenance of integral data, and information security but could not offer concrete approach to accommodate complex data structures of nested, hierarchical, and extensible type. These subtle restrictions led the adoption of OOPs concepts in database systems.

Object oriented model of database carries the essence of object oriented concepts like Inheritance, data instantiation and abstraction, and establishment of relationships among types. It ensures persistent data management, effective compatibility and integration with OOPs supported languages like C++, and JAVA, which are the best market flavors of application development.

The article shall be a fair effort to explore the Object model of Oracle. The scope of the study shall include the evolutionary background, comparative drive with RDBMS, commercial study and a lot more details. I shall present a sample case study to highlight the structure building implementation and demonstrate the working of common data tasks."

I shall post the link once the paper gets published at RMOUG journal.

Bye for now, SBH


Monday, 26 September 2011

Refresh constraints

 




[caption id="" align="alignright" width="158" caption="Image via CrunchBase"]Image representing Oracle Corporation as depic...[/caption]




Constraints are one of the fundamental concepts, which arrive at a very elementary stage of Database designing. Constraints are nothing but the rules on the data. This preserves the Entity integrity, Referential Integrity, and Domain Integrity of the data. While entity integrity focusses on uniqueness and NULLable property of a data, referential checks the data of a column 'in reference to' its parent column. Domain integrity defines a domain set for a column.

 They are imposed upon the table columns, where they act as barrier for the incoming data. Once the checks are activated, only the obedient data is allowed to grab the seat. System raises the 'Violating' exception, if the data fails the constraint rule.

My obligations to DBANotes.com, who published the content. Read the complete paper at the below link.

 http://www.dbanotes.com/database-development/understanding-oracle-11g-constraints/

Do post your feedback/comments/queries.

Saurabh

 

Tuesday, 13 September 2011

OakTable User Account

Hi,

Today, my user account at OakTable network(http://www.oaktable.net) has been approved. Just to share with you all, I am happy to be the subscribed user of OakTable N/W.
Thanks OakTable and Thanks all

SBH

[caption id="attachment_190" align="alignnone" width="150" caption=" "][/caption]

Sunday, 4 September 2011

Oracle 11g SecureFiles



[caption id="" align="alignright" width="300" caption="Image via Wikipedia"]Oracle Databases[/caption]


Hi All,

Oracle 11g saw through very significant PL/SQL feature i.e. Storage of external files/objects. These objects fall under unstructured data category and database recognises them as Large Objects. They are stored as LOB types in database. This normal storage was improved upon, after this philosophy slowly moved from 'featured one' to 'overhead' level in terms of application performance and security.

My obligations to Exforsys Inc, who have published my article on the usage of Oracle 11 Secure Files. Find the complete story at the link given below.

http://www.exforsys.com/tutorials/oracle-11g/oracle-11g-securefiles.html

Surely for the readers, come up with your comments, feedbacks and queries. I shall be thankful.

Bye, SBH

Wednesday, 17 August 2011

Refresh Oracle dependencies

Hi All,

Buzzzz !!!

From some time back, I was working on Oracle object dependencies. Oracle itself, is the director of all dependencies. I have compiled some of the concepts like dependency checks and verification, Fine grained concepts and version enhancements. Got the same published with Exforsys Inc. Check the same and post your queries/feedback/comments.

http://www.exforsys.com/tutorials/oracle-11g/manage-oracle-dependencies.html

Surely, it must thrust you to dig more into it. I shall be happy to see the reviews.

Over for now, SBH

Thursday, 11 August 2011

UTL_FILE

Hi All,

 

Hope u all r doing well !!

Check out my latest publication on UTL_FILE at Exforsys Inc

Working with UTL_FILE

Do post your feedbacks and queries.

Thanks !!

Bye, SBH

Sunday, 10 July 2011

Pragmas in Oracle

Hi Guyzz,

Check my publication at exforsys.com on Oracle Pragmas, updated until 11g version.

http://www.exforsys.com/tutorials/oracle-11g/oracle-pragma.html

I shall be happy to improvise upon your responses. Thanks !!

Bye for now-SBH

Wednesday, 29 June 2011

Conditional compilation in Oracle PL/SQL

Hi all,

Check out my latest publication at Exforsys.

Conditional compilation in Oracle PL/SQL.

Do read it and post your feedback.

Thanks, SBH

Saturday, 18 June 2011

Overloading in Oracle

Hi,

Overloading is a generic concept for a programming language. In conventional terms, it implies the different behavior of like named objects upon different calls. Different languages provide add ons upon overloading implementation, depending upon their language support and featured concepts.

I have recently got my article published at exforsys.com. Check it out the below link.

Oracle program overloading

Do post your feedback and comments.

Bye, SBH

 

Thursday, 16 June 2011

Read Only tables explained

Hi guyzz,

Check out my new online work at exforsys on Oracle 11g Read Only tables

Read Only Tables

Don't forget to post your feedback. These days bit busy with Object model, I'll be back soon with many more findings on Oracle stuffs.

Bye for now-SBH

Thursday, 9 June 2011

Wednesday, 8 June 2011

Check out "Recalling Oracle subprograms" on Oracle Community














Oracle Community
The social network for Oracle people















Saurabh Gupta

Saurabh Gupta
Check out the blog post 'Recalling Oracle subprograms'
Recall Oracle functions and procedures at Oracle Functions and Procedures

Blog post link:
Recalling Oracle subprograms

About Oracle Community
For anyone interested in Oracle databases, applications and related technologies.








 8691 members
486 photos
67 videos
953 discussions
213 Events
530 blog posts


 


Thursday, 2 June 2011

Oracle 11g Collections

Check out my new publication at exforsys.com

Oracle 11g Collections.

Do post your feedbacks.

Thanks - SBH

Monday, 30 May 2011

Oracle 11g Virtual Columns

Check out my latest publication

Oracle 11g Virtual Columns.

Do post your feedbacks !!

Check out "Invisible indexes" on Oracle Community














Oracle Community
The social network for Oracle people















Saurabh Gupta

Saurabh Gupta
Check out the blog post 'Invisible indexes'Hi,

View my latest publication..

http://www.exforsys.com/tutorials/oracle-11g/oracle-11g-invisible-index.html

Do post your feedback !!

Blog post link:
Invisible indexes

About Oracle Community
For anyone interested in Oracle databases, applications and related technologies.








 8655 members
486 photos
67 videos
948 discussions
212 Events
523 blog posts


 


Tuesday, 26 April 2011

Oracle Hints

Introduction

Performance is one of the primary objectives of a database. Fine tuned data retrieval and database operations can save lot of time for users and avoid troubleshoot nightmares of database developers.

The root cause of database performance degradation lies with the working of optimizer. Optimizer speed lowers and hence the query speed. There are multiple approaches and many ways to achieve database process performance. Thorough analysis of the data, explain plan is required to adopt the most feasible method to tune a SQL query

Out of these many approaches, Oracle SQL hints are one of the tricks to tune a query. SQL hints are optimizer directives which were introduced in Oracle 8.1.0 release. They instruct optimizer to follow an alternative path of query execution. At times, a developer can analyze a complex data better than an Optimizer. Therefore, he may choose a better execution plan than the optimizer by enforcing hints in the queries.  Like other approaches, it is not a full proof method of tuning but it is suggestible in case of complex queries.

SQL Hints Usage  Below are some situations when Hints are required to be used when the Optimizer fails:- 

  • Bugs

  • Use of Bind Variables which disable Histograms

  • Poorly written SQLs

  • High frequency of Change of Data

  • Faulty (incomplete) Configuration Settings

  • Dynamic vs. Static SQL 


Other circumstances where the use of Hints may be required:- 

  • Hints can be used to join external tables.

  • Hints can be used to force the optimizer to choose different join paths which will fetch different results in the query execution.

  • Hints are used to tell the optimizer which data access method to use (as for example in a flashback query). The method may be a full table scan or a different index. 


Note: - Sometimes, the optimizer can ‘lock’ the statistics when they look ideal. In such a case ‘Hints’ lose their importance.

Syntax:-  Hints appear as comments to the SELECT and DML statements. Without these keywords, they hold no meeting and would only appear as a comment. Hints can be used in any of the following ways: 

  • /*+ hint */

  • /*+ hint (argument) */

  • /*+ hint (argument-1 argument-2) */


Notes 

  • Hints can be used in SELECT, INSERT, UPDATE or DELETE statements

  • It can be a part of subquery too

  • It can appear in any of the participating queries of a compound query using SET operator

  • There should be no schema names in hints

  • All hints except the /*+ rule */ cause the Cost Based Optimizer (CBO) to be used

  • Hints operate on a simple view but not on a complex view 


Illustration 

1. The query below uses ALL_ROWS hint to select employee details from EMPLOYEE table 

SELECT /*+ ALL_ROWS */ EMPNO, ENAME, SALARY, DETPNO
FROM EMPLOYEE WHERE EMPNO=100


2. The SQL query below uses RULE hint to change the optimizer mode from COST based to RULE based

SELECT /*+ RULE */ EMPNO, ENAME, SALARY, DETPNO 

FROM EMPLOYEE WHERE EMPNO=100

3. The FULL hint used in the below SQL query enforces optimizer to do FULL TABLE SCAN

SELECT /*+ FULL(E) */ EMPNO, ENAME, SALARY

FROM EMPLOYEE E WHERE DEPTNO IN (SELECT DEPTNO 

                                 FROM DEPARTMENT

                                 WHERE LOCATION_ID=1009)

Types of Hints

Based on their usage area, SQL hints can be classified as below. 

  • Hints for Optimization Approaches and Goals

  • Hints for Access Paths, Hints for Query Transformations

  • Hints for Join Orders

  • Hints for Join Operations

  • Hints for Parallel Execution

  • Additional Hints 




























Hints for Optimization Approaches and Goals
HintFunctionUse
ALL_ROWSInvokes the CBOUsed for batch processing, data warehousing systems
FIRST_ROWSInvokes the CBOUsed for On Line Transfer Processing (OLTP) systems
CHOOSEInvokes the CBOIt lets the server choose between ALL_ROWS and FIRST_ROWS, based on the statistics gathered by the CBO

 Hints for Access Paths 























CLUSTERINDEXINDEX_FFS
FULLINDEX_ASCINDEX_JOIN
HASHINDEX_COMBINENO_INDEX
ROWIDINDEX_DESCAND_EQUAL

Hints for Query Transformations 























FACTNO_FACT
MERGENO_MERGE
NO_EXPANDNOREWRITE
NO_EXPAND_GSET_TO_UNIONREWRITE
USE_CONCATSTAR_TRANSFORMATION

Hints for Join Operations 























DRIVING_SITEMERGE_AJUSE_HASH
HASH_AJMERGE_SJUSE_MERGE
HASH_SJNL_AJUSE_NL
LEADINGNL_AJ 

 Hints for Parallel Execution 


















NO PARALLEL
PARALLEL
NOPARALLEL_INDEX
PARALLEL_INDEX
PQ_DISTRIBUTE

Miscellaneous Hints 



































































ANTIJOINDYNAMIC_SAMPLING
APPENDINLINE
BITMAPMATERIALIZE
BUFFERNO_ACCESS
CACHENO_BUFFER
CARDINALITYNO_MONITORING
CPU_COSTINGNO_PUSH_PRED
NO_PUSH_SUBQORDERED_PREDICATES
NO_QKN_BUFFPUSH_PRED
NO_SEMIJOINPUSH_SUBQ
NOAPPENDNOCACHE
STARSEMIJOIN
SWAP_JOIN_INPUTSSEMIJOIN_DRIVER
USE_ANTIOR_EXPAND
USE_SEMIORDERED
QB_NAMESELECTIVITY

Hint introduced in Oracle 11g 

RESULT_CACHE – The hint was introduced to cache the result of the SELECT query for the same set of inputs and values. It results in better performance if the same query has to be executed for multiple numbers of times.

Undocumented Hints 



















































































































BYPASS_RECURSIVE_CHECKCURSOR_SHARING_EXACT
BYPASS_UJVCDEREF_NO_REWRITE
CACHE_CBDML_UPDATE
CACHE_TEMP_TABLEDOMAIN_INDEX_NO_SORT
CIV_GBDOMAIN_INDEX_SORT
COLLECTIONS_GET_REFSDYNAMIC_SAMPLING
CUBE_GBDYNAMIC_SAMPLING_EST_CDN
SYS_PARALLEL_TXNSYS_RID_ORDER
REMOTE_MAPPEDRESTORE_AS_INTERVALS
SYS_DL_CURSORNO_UNNEST
SQLLDRUSE_TTT_FOR_GSETS
NESTED_TABLE_GET_REFSNESTED_TABLE_SET_SETID
NESTED_TABLE_SET_REFSNO_FILTERING
EXPAND_GSET_TO_UNIONPIV_GB
FORCE_SAMPLE_BLOCKTIV_GB
GBY_CONC_ROLLUPSAVE_AS_INTERVALS
GLOBAL_TABLE_HINTSNOCPU_COSTING
HWM_BROKEREDPQ_NOMAP
NO_PRUNE_GSETSNO_ORDER_ROLLUPS
INDEX_RRSSCN_ASCENDING
INDEX_SSOVERFLOW_NOMOVE
INDEX_SS_ASCPQ_MAP
INDEX_SS_DESCNO_STATS_GSETS
LIKE_EXPANDUNNEST
LOCAL_INDEXESSKIP_EXT_OPTIMIZER
MV_MERGEPIV_SSF
TIV_SSFIGNORE_ON_CLAUSE
IGNORE_WHERE_CLAUSE 

Obsolete Hints RULE – Its usage has been deprecated by Oracle after 9i release. Earlier, it used to work similar to the current COST hint i.e. to toggle over the optimizers.

Thursday, 21 April 2011

Hello Oracle

Hi Techizzzz,

I have started this blog to dump all my key experiences at one place and share the knowledge which may help the professionals from time to time.

I would wish to have your full support and I shall make sure we all have great TechFun here.

We are Oracles !!

SBH