Method: Sequel::DB2::DatabaseMethods#indexes

Defined in:
lib/sequel/adapters/shared/db2.rb

#indexes(table, opts = OPTS) ⇒ Object

Use SYSCAT.INDEXES to get the indexes for the table



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/sequel/adapters/shared/db2.rb', line 71

def indexes(table, opts = OPTS)
  m = output_identifier_meth
  table = table.value if table.is_a?(Sequel::SQL::Identifier)
  indexes = {}
  .
   from(Sequel[:syscat][:indexes]).
   select(:indname, :uniquerule, :colnames).
   where(:tabname=>input_identifier_meth.call(table), :system_required=>0).
   each do |r|
    indexes[m.call(r[:indname])] = {:unique=>(r[:uniquerule]=='U'), :columns=>r[:colnames][1..-1].split('+').map{|v| m.call(v)}}
  end
  indexes
end