Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find all the functional indexes on a column in Oracle

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?

like image 304
Darcy Casselman Avatar asked Dec 14 '09 21:12

Darcy Casselman


People also ask

Can you find out the indexes for a table in Oracle?

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.

What are function-based indexes in Oracle?

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.

What are functional indexes?

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.

Where are indexes stored in Oracle?

Indexes are stored in datafiles, that is also an database object.


2 Answers

The table user_ind_expressions describes expressions of function based indexes.

Oracle 11.2 link

like image 130
Khb Avatar answered Oct 21 '22 21:10

Khb


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
like image 33
Mike Avatar answered Oct 21 '22 21:10

Mike