use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class ExasolScriptManager method createOrReplaceScriptQuery.
private void createOrReplaceScriptQuery(List<DBEPersistAction> actions, ExasolScript script, Boolean replace) {
actions.add(new SQLDatabasePersistAction("Create Script", "OPEN SCHEMA " + script.getSchema().getName()));
if (replace) {
actions.add(new SQLDatabasePersistAction("Create Script", "DROP SCRIPT " + script.getFullyQualifiedName(DBPEvaluationContext.DDL)));
}
actions.add(new SQLDatabasePersistAction("Create Script: ", script.getSql(), true));
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class ExasolTableColumnManager method addObjectModifyActions.
// -----
// Alter
// -----
@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
ExasolTableColumn exasolColumn = command.getObject();
if (!command.getProperties().isEmpty()) {
// build nullability tring
String nullability = "";
if (exasolColumn.isOriRequired() != null && exasolColumn.isOriRequired() != exasolColumn.isRequired())
nullability = exasolColumn.isRequired() ? "NOT NULL" : "NULL";
final String deltaSQL = exasolColumn.getName() + " " + exasolColumn.getFormatType() + " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue()) + " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue()) + " " + nullability;
if (!deltaSQL.isEmpty()) {
String sqlAlterColumn = String.format(SQL_ALTER, exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sqlAlterColumn));
}
}
// Comment
DBEPersistAction commentAction = buildCommentAction(exasolColumn);
if (commentAction != null) {
actionList.add(commentAction);
}
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class SQLConstraintManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
final TABLE_TYPE table = command.getObject().getTable();
actions.add(new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_constraint, "ALTER TABLE " + table.getFullyQualifiedName(DBPEvaluationContext.DDL) + " ADD " + getNestedDeclaration(table, command)));
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class SQLForeignKeyManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
final TABLE_TYPE table = command.getObject().getTable();
actions.add(new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_foreign_key, //$NON-NLS-1$ //$NON-NLS-2$
"ALTER TABLE " + table.getFullyQualifiedName(DBPEvaluationContext.DDL) + " ADD " + getNestedDeclaration(table, command)));
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class SQLIndexManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
final TABLE_TYPE table = command.getObject().getTable();
final OBJECT_TYPE index = command.getObject();
// Create index
final String indexName = DBUtils.getQuotedIdentifier(index.getDataSource(), index.getName());
index.setName(indexName);
StringBuilder decl = new StringBuilder(40);
decl.append("CREATE ");
if (index.isUnique()) {
decl.append("UNIQUE ");
}
//$NON-NLS-1$
decl.append("INDEX ").append(indexName).append(" ON ").append(//$NON-NLS-1$
table.getFullyQualifiedName(DBPEvaluationContext.DDL)).append(//$NON-NLS-1$
" (");
try {
// Get columns using void monitor
boolean firstColumn = true;
for (DBSTableIndexColumn indexColumn : CommonUtils.safeCollection(command.getObject().getAttributeReferences(VoidProgressMonitor.INSTANCE))) {
//$NON-NLS-1$
if (!firstColumn)
decl.append(",");
firstColumn = false;
decl.append(indexColumn.getName());
appendIndexColumnModifiers(decl, indexColumn);
}
} catch (DBException e) {
log.error(e);
}
//$NON-NLS-1$
decl.append(")");
actions.add(new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_index, decl.toString()));
}
Aggregations