use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class DB2SchemaManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
SQLDatabasePersistAction action = new SQLDatabasePersistAction("Create schema", String.format(SQL_CREATE_SCHEMA, DBUtils.getQuotedIdentifier(command.getObject())));
actions.add(action);
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class DB2SequenceManager method addObjectDeleteActions.
@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command) {
String sql = String.format(SQL_DROP, command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL));
DBEPersistAction action = new SQLDatabasePersistAction("Drop Sequence", sql);
actions.add(action);
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class PostgreTableColumnManager method addObjectModifyActions.
@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
final PostgreAttribute column = command.getObject();
// PostgreSQL can't perform all changes by one query
// ALTER [ COLUMN ] column [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]
// ALTER [ COLUMN ] column SET DEFAULT expression
// ALTER [ COLUMN ] column DROP DEFAULT
// ALTER [ COLUMN ] column { SET | DROP } NOT NULL
// ALTER [ COLUMN ] column SET STATISTICS integer
// ALTER [ COLUMN ] column SET ( attribute_option = value [, ... ] )
// ALTER [ COLUMN ] column RESET ( attribute_option [, ... ] )
// ALTER [ COLUMN ] column SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
String prefix = "ALTER TABLE " + DBUtils.getObjectFullName(column.getTable(), DBPEvaluationContext.DDL) + " ALTER COLUMN " + DBUtils.getQuotedIdentifier(column) + " ";
String typeClause = column.getFullTypeName();
if (column.getDataType() != null) {
typeClause += " USING " + DBUtils.getQuotedIdentifier(column) + "::" + column.getDataType().getName();
}
if (command.getProperty("dataType") != null || command.getProperty("maxLength") != null || command.getProperty("precision") != null || command.getProperty("scale") != null) {
actionList.add(new SQLDatabasePersistAction("Set column type", prefix + "TYPE " + typeClause));
}
if (command.getProperty("required") != null) {
actionList.add(new SQLDatabasePersistAction("Set column nullability", prefix + (column.isRequired() ? "SET" : "DROP") + " NOT NULL"));
}
if (command.getProperty("defaultValue") != null) {
if (CommonUtils.isEmpty(column.getDefaultValue())) {
actionList.add(new SQLDatabasePersistAction("Drop column default", prefix + "DROP DEFAULT"));
} else {
actionList.add(new SQLDatabasePersistAction("Set column default", prefix + "SET DEFAULT " + column.getDefaultValue()));
}
}
if (command.getProperty("description") != null) {
actionList.add(new SQLDatabasePersistAction("Set column comment", "COMMENT ON COLUMN " + DBUtils.getObjectFullName(column.getTable(), DBPEvaluationContext.DDL) + "." + DBUtils.getQuotedIdentifier(column) + " IS '" + SQLUtils.escapeString(CommonUtils.toString(column.getDescription())) + "'"));
}
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class PostgreTableManager method addObjectModifyActions.
@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
final PostgreTableBase table = command.getObject();
if (command.getProperties().size() > 1 || command.getProperty("description") == null) {
//$NON-NLS-1$
StringBuilder query = new StringBuilder("ALTER TABLE ");
//$NON-NLS-1$
query.append(table.getFullyQualifiedName(DBPEvaluationContext.DDL)).append(" ");
appendTableModifiers(table, command, query);
actionList.add(new SQLDatabasePersistAction(query.toString()));
}
}
use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.
the class PostgreDatabaseManager method addObjectCreateActions.
@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
final PostgreDatabase database = command.getObject();
actions.add(//$NON-NLS-2$
new SQLDatabasePersistAction("Create database", "CREATE DATABASE " + DBUtils.getQuotedIdentifier(database)));
}
Aggregations