Skip to content

Commit

Permalink
Update ObReaderUtils.java
Browse files Browse the repository at this point in the history
OceanBase oracle模式下需要使用position排序获取正确的联合主键顺序
  • Loading branch information
lvfuyou authored Mar 18, 2024
1 parent 072b24f commit 8968283
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ private static String[] getPkColumns(Connection conn, TaskContext context) {
} else {
schema = "(select sys_context('USERENV','current_schema') from dual)";
}
//OceanBase oracle模式下需要使用position排序获取正确的联合主键顺序
sql = String.format(
"SELECT cols.column_name Column_name " +
"FROM all_constraints cons, all_cons_columns cols " +
"WHERE cols.table_name = '%s' AND cons.constraint_type = 'P' " +
"AND cons.constraint_name = cols.constraint_name " +
"AND cons.owner = cols.owner and cons.OWNER = %s",
"AND cons.owner = cols.owner and cons.OWNER = %s " +
"order by cols.position " ,
tableName, schema);
}
LOG.info("get primary key by sql: " + sql);
Expand Down

0 comments on commit 8968283

Please sign in to comment.