Search in sources :

Example 31 with SQLDatabasePersistAction

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

the class OracleSequenceManager method addObjectDeleteActions.

@Override
protected void addObjectDeleteActions(List<DBEPersistAction> actions, ObjectDeleteCommand command) {
    String sql = "DROP SEQUENCE " + command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL);
    DBEPersistAction action = new SQLDatabasePersistAction("Drop Sequence", sql);
    actions.add(action);
}
Also used : DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 32 with SQLDatabasePersistAction

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

the class OracleTableColumnManager method addObjectRenameActions.

@Override
protected void addObjectRenameActions(List<DBEPersistAction> actions, ObjectRenameCommand command) {
    final OracleTableColumn column = command.getObject();
    actions.add(new SQLDatabasePersistAction("Rename column", "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " RENAME COLUMN " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getOldName()) + " TO " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getNewName())));
}
Also used : OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 33 with SQLDatabasePersistAction

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

the class OracleTableColumnManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
    final OracleTableColumn column = command.getObject();
    boolean hasComment = command.getProperty("comment") != null;
    if (!hasComment || command.getProperties().size() > 1) {
        actionList.add(new SQLDatabasePersistAction("Modify column", //$NON-NLS-1$
        "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " MODIFY " + //$NON-NLS-1$
        getNestedDeclaration(column.getTable(), command)));
    }
    if (hasComment) {
        actionList.add(new SQLDatabasePersistAction("Comment column", "COMMENT ON COLUMN " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + "." + DBUtils.getQuotedIdentifier(column) + " IS '" + column.getComment(VoidProgressMonitor.INSTANCE) + "'"));
    }
}
Also used : OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 34 with SQLDatabasePersistAction

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

the class OracleTableManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
    if (command.getProperties().size() > 1 || command.getProperty("comment") == null) {
        //$NON-NLS-1$
        StringBuilder query = new StringBuilder("ALTER TABLE ");
        //$NON-NLS-1$
        query.append(command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL)).append(" ");
        appendTableModifiers(command.getObject(), command, query);
        actionList.add(new SQLDatabasePersistAction(query.toString()));
    }
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 35 with SQLDatabasePersistAction

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

the class OracleViewManager method createOrReplaceViewQuery.

private void createOrReplaceViewQuery(List<DBEPersistAction> actions, DBECommandComposite<OracleView, PropertyHandler> command) {
    final OracleView view = command.getObject();
    boolean hasComment = command.getProperty("comment") != null;
    if (!hasComment || command.getProperties().size() > 1) {
        actions.add(new SQLDatabasePersistAction("Create view", view.getAdditionalInfo().getText()));
    }
    if (hasComment) {
        actions.add(new SQLDatabasePersistAction("Comment table", "COMMENT ON TABLE " + view.getFullyQualifiedName(DBPEvaluationContext.DDL) + " IS '" + view.getComment() + "'"));
    }
}
Also used : OracleView(org.jkiss.dbeaver.ext.oracle.model.OracleView) 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