I'm new to SQL on the iSeries -- being an old school programmer -- so this may seem like a dumb question. Traditionally, we can create a logical file that does not only select, but indexes. How can I do this in SQL? If I create a view with selection criteria, can I index it? I don't believe I can create an index with selection criteria.
SQL Views cannot be indexed -- this is defined in the SQL standard. With SQL you create your Views and then create indexes over the tables referenced by the View. Then when your database requests access the SQL View, it's the query optimizer's job to find an index to use when accessing your data through the specified SQL View.
You might want to read the Indexing strategies for DB2 UDB for iSeries white paper for more details on how the query optimizer utilizes indexes.
MORE INFORMATION ON THIS TOPIC
Search400.com's targeted search engine: Get relevant information on DB2/400.
The Best Web Links: tips, tutorials and more.
Check out this Search400.com Featured Topic: Database issues resolved
Dig Deeper on DB2 UDB (universal databases)
Related Q&A from Kent Milligan
To solve the SQL error -321 on IBM i6.1, use the new values statement to overcome the error. If you are using an older release, declare a cursor ... Continue Reading
When working with DB2 files with columns that have both short and long names, there is no option choose which column names are returned via ODBC ... Continue Reading
When developing tables in a parent-child relationship, use a primary key and a foreign key along with a unique ID to make your database easier to ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.