Search in sources :

Example 1 with SQLDatabasePersistAction

use of org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction in project dbeaver by serge-rider.

the class ExasolViewManager method addObjectDeleteActions.

@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, SQLObjectEditor<ExasolView, ExasolSchema>.ObjectDeleteCommand<ExasolView, ExasolSchema> command) {
    ExasolView view = (ExasolView) command.getObject();
    actions.add(new SQLDatabasePersistAction("Drop view", "DROP VIEW " + view.getFullyQualifiedName(DBPEvaluationContext.DDL)));
}
Also used : ExasolView(org.jkiss.dbeaver.ext.exasol.model.ExasolView) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 2 with SQLDatabasePersistAction

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));
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 3 with SQLDatabasePersistAction

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);
    }
}
Also used : DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 4 with SQLDatabasePersistAction

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)));
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 5 with SQLDatabasePersistAction

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)));
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Aggregations

SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)55 DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)10 DBException (org.jkiss.dbeaver.DBException)3 MySQLTableColumn (org.jkiss.dbeaver.ext.mysql.model.MySQLTableColumn)3 DB2TableColumn (org.jkiss.dbeaver.ext.db2.model.DB2TableColumn)2 ExasolTableColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)2 OracleTableColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)2 ArrayList (java.util.ArrayList)1 NotNull (org.jkiss.code.NotNull)1 ExasolView (org.jkiss.dbeaver.ext.exasol.model.ExasolView)1 GenericDataSource (org.jkiss.dbeaver.ext.generic.model.GenericDataSource)1 MySQLCatalog (org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog)1 MySQLDataSource (org.jkiss.dbeaver.ext.mysql.model.MySQLDataSource)1 MySQLView (org.jkiss.dbeaver.ext.mysql.model.MySQLView)1 OracleDataType (org.jkiss.dbeaver.ext.oracle.model.OracleDataType)1 OracleUser (org.jkiss.dbeaver.ext.oracle.model.OracleUser)1 OracleView (org.jkiss.dbeaver.ext.oracle.model.OracleView)1 PostgreDatabase (org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase)1 PostgreRole (org.jkiss.dbeaver.ext.postgresql.model.PostgreRole)1 PostgreSchema (org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)1