Query to check index on a table

后端 未结 10 1713
南方客
南方客 2020-12-13 06:06

I need a query to see if a table already has any indexes on it.

10条回答
  •  执念已碎
    2020-12-13 06:38

    On Oracle:

    • Determine all indexes on table:

      SELECT index_name 
       FROM user_indexes
       WHERE table_name = :table
      
    • Determine columns indexes and columns on index:

      SELECT index_name
           , column_position
           , column_name
        FROM user_ind_columns
       WHERE table_name = :table
       ORDER BY index_name, column_order
      

    References:

    • ALL_IND_COLUMNS
    • ALL_INDEXES

提交回复
热议问题