Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see a list of all the indexes (including implicit ones) in SQL*Plus?

Is there some way to get a list of all the indexes on a particular table using SQL*Plus?

I created a table

CREATE TABLE temp(
id NUMBER PRIMARY KEY,
name VARCHAR2(20));

There should be an implicit index created on the primary key (id). How can I see that index?

SELECT * FROM all_indexes WHERE table_name = 'temp';

gives

no rows selected

like image 322
Moeb Avatar asked Aug 11 '10 12:08

Moeb


People also ask

How do I list all indexes in SQL Server?

You can use the sp_helpindex to view all the indexes of one table. And for all the indexes, you can traverse sys. objects to get all the indexes for each table. Only problem with this is that it only includes the index key columns, not the included columns.

How do I view indexes in SQL?

To see the index for a specific table use SHOW INDEX: SHOW INDEX FROM yourtable; To see indexes for all tables within a specific schema you can use the STATISTICS table from INFORMATION_SCHEMA: SELECT DISTINCT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.


1 Answers

SELECT INDEX_NAME FROM ALL_INDEXES WHERE TABLE_NAME = 'your_table'

Note: If you want to limit the search to a specific schema, you can also do:

SELECT INDEX_NAME FROM ALL_INDEXES WHERE TABLE_NAME = 'your_table' AND OWNER = 'your_owner'

This is useful in situations where you might have the same table name in multiple schemas.

Also, keep in mind that Oracle stores the table names as upper case, so in your example you need to do:

select * from all_indexes where table_name = 'TEMP';
like image 183
dcp Avatar answered Sep 30 '22 16:09

dcp