Say I have a program that searches a database for columns to modify, as part of a database conversion process.
If I attempt to alter a column with a functional index defined gives the following error:
ORA-30556: functional index is defined on the column to be modified
Looking up the ORA code, the solution is to "Drop the functional index before attempting to modify the column."
Great! So how do I find all the functional indexes on that column?
The user_ind_columns
view looks like a good start, but functional indexes have things like "SYS_NC00042$" in their COLUMN
column. Looking around the other user_
views, I'm not seeing anything obvious. Am I missing something?
Or am I going about this the wrong way entirely?
To list only the indexes on a table, query the all_indexes view: SELECT index_name, index_type, uniqueness FROM all_indexes WHERE owner = UPPER('&owner') AND table_name = UPPER('&table_name'); Listing the indexes alone is seldom enough. You need to know at least the columns involved in each index.
Function-based indexes allow you to create an index based on a function or expression. The value of the function or expression is specified by the person creating the index and is stored in the index. Function-based indexes can involve multiple columns, arithmetic expressions, or maybe a PL/SQL function or C callout.
A functional index is one in which all keys derive from the results of a function. If you have a column of pictures, for example, and a function to identify the predominant color, you can create an index on the result of the function.
Indexes are stored in datafiles, that is also an database object.
The table user_ind_expressions
describes expressions of function based indexes.
Oracle 11.2 link
Look at the INDEX_TYPE
column of USER_INDEXES
:
select table_name, index_name, index_type
from user_indexes
where index_type like 'FUNCTION%'
order by table_name, index_name
TABLE_NAME INDEX_NAME INDEX_TYPE
------------------------------ ------------------------------ ---------------------------
SOME_TABLE SOME_TABLE_FUNC_INDEX FUNCTION-BASED NORMAL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With