Search in sources :

Example 46 with SQLDatabasePersistAction

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

the class MySQLCatalogManager method addObjectCreateActions.

@Override
protected void addObjectCreateActions(List<DBEPersistAction> actions, ObjectCreateCommand command) {
    final MySQLCatalog catalog = command.getObject();
    final StringBuilder script = new StringBuilder("CREATE SCHEMA `" + catalog.getName() + "`");
    if (catalog.getDefaultCharset() != null) {
        script.append("\nDEFAULT CHARACTER SET ").append(catalog.getDefaultCharset().getName());
    }
    if (catalog.getDefaultCollation() != null) {
        script.append("\nDEFAULT COLLATE ").append(catalog.getDefaultCollation().getName());
    }
    actions.add(//$NON-NLS-2$
    new SQLDatabasePersistAction("Create schema", script.toString()));
}
Also used : MySQLCatalog(org.jkiss.dbeaver.ext.mysql.model.MySQLCatalog) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 47 with SQLDatabasePersistAction

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

the class MySQLTableColumnManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
    final MySQLTableColumn column = command.getObject();
    actionList.add(new SQLDatabasePersistAction("Modify column", //$NON-NLS-1$ //$NON-NLS-2$
    "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " MODIFY COLUMN " + getNestedDeclaration(column.getTable(), command)));
}
Also used : MySQLTableColumn(org.jkiss.dbeaver.ext.mysql.model.MySQLTableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 48 with SQLDatabasePersistAction

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

the class MySQLTableColumnManager method addObjectRenameActions.

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

Example 49 with SQLDatabasePersistAction

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

the class MySQLTableManager method addObjectRenameActions.

@Override
protected void addObjectRenameActions(List<DBEPersistAction> actions, ObjectRenameCommand command) {
    final MySQLDataSource dataSource = command.getObject().getDataSource();
    actions.add(new SQLDatabasePersistAction("Rename table", //$NON-NLS-1$
    "RENAME TABLE " + command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL) + " TO " + DBUtils.getQuotedIdentifier(command.getObject().getContainer()) + "." + //$NON-NLS-1$
    DBUtils.getQuotedIdentifier(dataSource, command.getNewName())));
}
Also used : SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 50 with SQLDatabasePersistAction

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

the class MySQLTableManager method addObjectModifyActions.

@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
    //$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)

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