Chapter 3 Building Physical Diagrams
In some DBMS, you can create indexes on functions and expressions that involve one or more columns in the table being indexed. A function-based index precomputes the value of the function or expression and stores it in the index. The function or the expression will replace the index column in the index definition.
Function-based indexes provide an efficient mechanism for evaluating statements that contain functions in their WHERE clauses.
An index column with an expression has a LONG data type that cannot be concatenated in a string statement during reverse engineering. The only way to bypass this limitation and concatenate this value is to use variables in the query executed to retrieve the adequate information.
In the Oracle 8i and Oracle 8i2 DBMS, the query SqlListQuery
defined in the Index category contains the following variable used to recover the index expression in a column with the LONG data type.
'%SqlExpression.Xpr'||i.table_name||i.index_name||c.column_position||'%'
For more information on the use of variables in reverse engineering queries, see section Extension mechanism for ODBC reverse engineering queries, in chapter DBMS Reference Guide, in the Advanced User Documentation .
Function-based indexes defined on UPPER(column_name) or LOWER(column_name) can facilitate case-insensitive searches.
You want to define an index that will put all names in lowercase on the table EMPLOYEE in order to ease search. You can define the following index (syntax for Oracle 8i):
CREATE INDEX low_name_idx ON EMPLOYEE (LOWER(EMPLNAM))
Then the DBMS can use it when processing queries such as:
SELECT * FROM EMPLOYEE WHERE LOWER(EMPLNAM)="brown"
To create a function-based index:
Copyright (C) 2005. Sybase Inc. All rights reserved. |