How to specify a hint

A hint is provided to the cost-based optimizer in the form of a comment within the SQL statement. Specifically, after you begin the comment (with either the “- -” or “/* " comment syntax), start the hint with a “+ " followed by the specific hint. If the hint is not properly formatted, it will not be honored.

Warning

The cost-based optimizer is unable to distinguish between an incorrectly specified hint and a comment. If you do not use correct syntax to provide the hint, not only will the hint not be taken, no error message will be generated.

Following are two ways you can specify the same hint:

SELECT /*+ RULE */  emp, ename, job, dname
FROM emp,dept
WHERE emp.deptno = dept.deptno;

SELECT --+ RULE
emp, ename, job, dname
FROM emp,dept
WHERE emp.deptno = dept.deptno;

Get Oracle Database Administration: The Essential Refe now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.