| SELECT | ind.Index_name "Name", ind.index_type "Type", ind.uniqueness "Unique?", |
| col.column_name "Column Name", col.column_position "Position", col.descend "Asc/Desc" | |
| FROM | all_indexes ind, all_ind_columns col |
| WHERE | ind.table_name = col.table_name |
| AND | ind.table_owner = col.table_owner |
| AND | ind.index_name = col.index_name |
| AND | ind.table_name = '&&table' |
| / |
To run the code, cut and paste it onto your favourite editor and save the file to say index.sql.
At the SQL*PLUS prompt, execute the script using the syntax 'SQL>@index'. The script prompts you for the name of the table. It
then displays information w.r.t the indexes created for the table.
For the emp table, for example, you get the
following output.
SQL>@index
Please enter your table name: EMP
| Wed May 09 | page 1 | ||||
| Indexes for | table EMP | ||||
| Name | Type | Unique? | Column Name | Position | Asc/Desc |
| ------------------------------ | --------------------------- | --------- | ------------------------------ | --------- | -------- |
| PK_EMP | NORMAL | UNIQUE | EMPNO | 1 | ASC |