提交 e1166b14 authored 作者: Thomas Mueller's avatar Thomas Mueller

Script command and tool: the primary key constraint is now listed before inserting the data.

上级 cb59d337
...@@ -206,6 +206,14 @@ public class ScriptCommand extends ScriptBase { ...@@ -206,6 +206,14 @@ public class ScriptCommand extends ScriptBase {
} }
String tableType = table.getTableType(); String tableType = table.getTableType();
add(sql, false); add(sql, false);
ObjectArray<Constraint> constraints = table.getConstraints();
if (constraints != null) {
for (Constraint constraint : constraints) {
if (Constraint.PRIMARY_KEY.equals(constraint.getConstraintType())) {
add(constraint.getCreateSQLWithoutIndexes(), false);
}
}
}
if (Table.TABLE.equals(tableType)) { if (Table.TABLE.equals(tableType)) {
if (table.canGetRowCount()) { if (table.canGetRowCount()) {
String rowcount = "-- " + table.getRowCountApproximation() + " +/- SELECT COUNT(*) FROM " String rowcount = "-- " + table.getRowCountApproximation() + " +/- SELECT COUNT(*) FROM "
...@@ -291,7 +299,9 @@ public class ScriptCommand extends ScriptBase { ...@@ -291,7 +299,9 @@ public class ScriptCommand extends ScriptBase {
}); });
for (SchemaObject obj : constraints) { for (SchemaObject obj : constraints) {
Constraint constraint = (Constraint) obj; Constraint constraint = (Constraint) obj;
add(constraint.getCreateSQLWithoutIndexes(), false); if (!Constraint.PRIMARY_KEY.equals(constraint.getConstraintType())) {
add(constraint.getCreateSQLWithoutIndexes(), false);
}
} }
for (SchemaObject obj : db.getAllSchemaObjects(DbObject.TRIGGER)) { for (SchemaObject obj : db.getAllSchemaObjects(DbObject.TRIGGER)) {
TriggerObject trigger = (TriggerObject) obj; TriggerObject trigger = (TriggerObject) obj;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论