Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Selecting data using index
There is hint INDEX(table_name index_name )
This brings optimizer use index if it's created.
Also you have to write some dummy comparison operator for (first) indexed
column(s),
if you want select all records.
select /*+ INDEX(E employees_ssn_idx) */ ssn
from employees E
where ssn>0;
If this index not created optimizer will ignore this hint. Query will be executed any way without error.
Regards,
Mark Malakanov
Juan Carlos <jc_va_at_hotmail.com> wrote in message
news:7lngd7$nof$1_at_bgtnsc01.worldnet.att.net...
> I believe I heard that when you "select ssn from employees" and ssn is
> indexed, that oracle may use the index, if the column(s) are contained in
> the index. Further, I know you can give a hint to "suggest" it use the
> index. But it doesn't sound like a good idea to write production code
> relying on this because someone can change the optimizer (delete stats) or
> drop the index. Is there a way to "force" oracle to use the index, or
> return an error if it can't for some reason? Thanks.
>
>
Received on Sun Jul 04 1999 - 08:17:26 CDT