Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v1.2.6) is shown here.
pk_and_sequence_for(table_name)
public
Find a table’s primary key and sequence. Note: Only primary
key is implemented - sequence will be nil.
# File activerecord/lib/active_record/connection_adapters/oracle_adapter.rb, line 395
def pk_and_sequence_for(table_name)
(owner, table_name) = @connection.describe(table_name)
pks = select_values("select cc.column_name\nfrom all_constraints c, all_cons_columns cc\nwhere c.owner = '\#{owner}'\nand c.table_name = '\#{table_name}'\nand c.constraint_type = 'P'\nand cc.owner = c.owner\nand cc.constraint_name = c.constraint_name\n", 'Primary Key')
# only support single column keys
pks.size == 1 ? [oracle_downcase(pks.first), nil] : nil
end