Skip to content

Instantly share code, notes, and snippets.

@redsfyre
Last active October 3, 2022 07:36
Show Gist options
  • Save redsfyre/95d45f788e02ae820125d58aff2f5474 to your computer and use it in GitHub Desktop.
Save redsfyre/95d45f788e02ae820125d58aff2f5474 to your computer and use it in GitHub Desktop.
Oracle DB list table indexes and their columns for specific table
select index_name, column_name from user_ind_columns where table_name='&tablename';
-- Enter table name after running this query
-- dba_ind_columns : This is to used if login with user having DBA role
-- all_ind_columns : This is to used if login with user having normal role
-- user_ind_columns : This is to used if login with user having normal role
-- OK nvm, this one is better;
set pagesize 50000 verify off echo off
col table_name head 'Table Name' format a30
col index_name head 'Index Name' format a30
col column_name head 'Column Name' format a30
break on table_name on index_name
select table_name, index_name, column_name
from all_ind_columns
where table_name like upper('&Table_Name')
order by table_name, index_name, column_position
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment