How do I get information about an index and table owner in Oracle?
The following may help give you want you need:
SELECT
index_owner, index_name, table_name, column_name, column_position
FROM DBA_IND_COLUMNS
ORDER BY
index_owner,
table_name,
index_name,
column_position
;
For my use case, I wanted the column_names and order that they are in the indices (so that I could recreate them in a different database engine after migrating to AWS). The following was what I used, in case it is of use to anyone else:
SELECT
index_name, table_name, column_name, column_position
FROM DBA_IND_COLUMNS
WHERE
INDEX_OWNER = 'FOO'
AND TABLE_NAME NOT LIKE '%$%'
ORDER BY
table_name,
index_name,
column_position
;
select index_name, column_name
from user_ind_columns
where table_name = 'NAME';
OR use this:
select TABLE_NAME, OWNER
from SYS.ALL_TABLES
order by OWNER, TABLE_NAME
And for Indexes:
select INDEX_NAME, TABLE_NAME, TABLE_OWNER
from SYS.ALL_INDEXES
order by TABLE_OWNER, TABLE_NAME, INDEX_NAME
According to the docs, you can just do:
select INDEX_NAME, TABLE_OWNER, TABLE_NAME, UNIQUENESS from USER_INDEXES
or
select INDEX_NAME, TABLE_OWNER, TABLE_NAME, UNIQUENESS from ALL_INDEXES
if you want all indexes...
The following helped me as I didn't have DBA access and also wanted the column names.
See: https://dataedo.com/kb/query/oracle/list-table-indexes
select ind.table_owner || '.' || ind.table_name as "TABLE",
ind.index_name,
LISTAGG(ind_col.column_name, ',')
WITHIN GROUP(order by ind_col.column_position) as columns,
ind.index_type,
ind.uniqueness
from sys.all_indexes ind
join sys.all_ind_columns ind_col
on ind.owner = ind_col.index_owner
and ind.index_name = ind_col.index_name
where ind.table_owner not in ('ANONYMOUS','CTXSYS','DBSNMP','EXFSYS',
'MDSYS', 'MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS',
'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST',
'WKPROXY','WMSYS','XDB','APEX_040000','APEX_040200',
'DIP', 'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM', 'XS$NULL',
'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'PUBLIC',
'LBACSYS', 'OUTLN', 'WKSYS', 'APEX_PUBLIC_USER')
-- AND ind.table_name='TableNameGoesHereIfYouWantASpecificTable'
group by ind.table_owner,
ind.table_name,
ind.index_name,
ind.index_type,
ind.uniqueness
order by ind.table_owner,
ind.table_name;