Forum Stats

  • 3,751,483 Users
  • 2,250,366 Discussions
  • 7,867,436 Comments

Discussions

correct index hint syntax

810790
810790 Member Posts: 3
edited Aug 27, 2012 8:27AM in General Database Discussions
Hi all

Please tell me what is the correct syntax for using hints

1 . select /*+ index (employees emp_dept_idx) +/ employee_id, department_id from employees where department_id > 10;

2. select /*+ index (mytab name_idx) */ id from mytab where name <> 'HARRY'

3. select /*+ index_combine(e emp_manager_ix emp_department_ix) */ * from employees e where manager_id = 110 or department_id=120;

Please specify it if all the above syntax are valid in which case these are valid.

thanks in advance
Tagged:

Answers

  • sb92075
    sb92075 Member Posts: 42,196 Blue Diamond
    807787 wrote:
    Hi all

    Please tell me what is the correct syntax for using hints

    1 . select /*+ index (employees emp_dept_idx) +/ employee_id, department_id from employees where department_id > 10;
    select employee_id, department_id from employees where department_id > 10;
    2. select /*+ index (mytab name_idx) */ id from mytab where name <> 'HARRY'
    select id from mytab where name <> 'HARRY';
    3. select /*+ index_combine(e emp_manager_ix emp_department_ix) */ * from employees e where manager_id = 110 or department_id=120;
    select * from employees e where manager_id = 110 or department_id=120;

    You are advised to NOT use any hint.
  • 810790
    810790 Member Posts: 3
    edited Aug 24, 2012 1:51PM
    Thanks for reply

    But it is not clearing the difference the syntax between

    1 . /*+ index +/

    2. /*+ index */

    please clear the difference between the above syntax

    Edited by: 807787 on Aug 24, 2012 10:51 AM
  • Centinul
    Centinul Member Posts: 6,871 Bronze Crown
    It's best to read the manual: Hints
  • sb92075
    sb92075 Member Posts: 42,196 Blue Diamond
    807787 wrote:
    Thanks for reply

    But it is not clearing the difference the syntax between

    1 . /*+ index +/

    2. /*+ index */

    please clear the difference between the above syntax

    Edited by: 807787 on Aug 24, 2012 10:51 AM
    http://www.lmgtfy.com/?q=oracle+index+hint
  • 810790
    810790 Member Posts: 3
    Thanks for reply

    But i didn't found the meaning of

    /*+ index +/
  • Centinul
    Centinul Member Posts: 6,871 Bronze Crown
    The documentation was explicit about how to properly format comments to be interpreted as hints. Therefore anything that does not fit that definition is just a comment.
    Centinul
  • >
    Therefore anything that does not fit that definition is just a comment.
    >
    Or is a syntax error since that comment syntax has to end with */ and not +/
  • Centinul
    Centinul Member Posts: 6,871 Bronze Crown
    rp0428 wrote:
    >
    Therefore anything that does not fit that definition is just a comment.
    >
    Or is a syntax error since that comment syntax has to end with */ and not +/
    Good point, I missed that one ;-)

    Thanks!
This discussion has been closed.