Link to home
Start Free TrialLog in
Avatar of AC032698
AC032698

asked on

How to use specific index with SELECT

I develop database applications with Delphi 3 based on Oracle 7.3.2 and local Paradox tables. I want to be able to use a definite index in SELECT clauses (I don't want an index to be automatically selected if available by DB system). Need two simple examples about syntax, one for Paradox and one for Oracle, if they are different.
Avatar of jhunt
jhunt

try:
SELECT * FROM EXAMPLE_TABLE
ORDER BY FIELD1+FIELD2

The DBMS will select the right index (or combination of indexes) for you. This works on both oracle and paradox.

John
Avatar of AC032698

ASKER

I said that I want to use an index determined by ME, even though it might be worse than any automatically selected index. Also, a SELECT clause with ORDER BY gives a read-only result set.
SELECT * FROM TABLE INDEX=NAME

That will do the Job I guess :-)
You can also gives an index ID insteed of the name
I am sorry but it does not work. Have you ever tried it??
Well it comes from the SQL server documentation never tried with ORACLE or PARADOX :-)
SELECT  *  FROM {table_name | view_name}[(optimizer_hints)]
[, {table_name2 | view_name2}[(optimizer_hints)]

where

(optimizer_hints)

Indicate that a specific locking method, a specific index, or no index (table scan) should be used (by the optimizer) with this table for this SELECT.

INDEX = {index_name | index_id}

Specifies the index name or ID to use for that table.



This is the same answer as mine AC ;-) Maybe do you have to give the exact SQL with the right table name and the right index to make it work :-)
Thank you for your interest friends. I, too,  have some documents and some URLs describing the specific index usage, quite similar to yours. But they don't work. I tried almost all kinds with Paradox, Oracle and Adabas ODBC. I don't think that I use wrong index name, number, etc. What I really need is just an example which is really tried by an experienced expert.
ASKER CERTIFIED SOLUTION
Avatar of sganta
sganta

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi sganta!
It is great answer! Thank you very much. And Jesus loves you as well; excellent grade.