Class AlterTable
This object may be used to dynamically construct a SQL statement in a
database-independent fashion. After it is finished, it may be executed using
DbQueryManager.executeUpdate().
Each AlterTable instance performs exactly one alteration, since
that is the only form that all the databases support. When you need several
alterations, you simply execute them as a series of AlterTable
queries.
The alterColumnType alteration restates the complete column
definition on the databases that require it, like MySQL and Oracle, so that
the nullability and the default that you provide with it become part of the
restated definition. Databases that alter the type in isolation only change
the type, which means that you have to alter the nullability and the default
there with the dedicated alterColumnNullable and
alterColumnDefault alterations.
- Since:
- 1.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumProvides the alterations that anAlterTablequery can perform. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CreateTable.ViolationActionprotected Datasourceprotected booleanstatic final CreateTable.ViolationActionstatic final CreateTable.Nullablestatic final CreateTable.Nullablestatic final CreateTable.ViolationActionstatic final CreateTable.ViolationActionstatic final CreateTable.ViolationActionprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddColumn(String name, Class type, int precision, int scale, String typeAttribute, CreateTable.Nullable nullable) addColumn(String name, Class type, int precision, int scale, CreateTable.Nullable nullable) addColumn(String name, Class type, int precision, String typeAttribute, CreateTable.Nullable nullable) addColumn(String name, Class type, int precision, CreateTable.Nullable nullable) addColumn(String name, Class type, String typeAttribute, CreateTable.Nullable nullable) addColumn(String name, Class type, CreateTable.Nullable nullable) addColumn(String name, String customType, CreateTable.Nullable nullable) addForeignKey(String foreignTable, String[] columnsMapping) addForeignKey(String foreignTable, String[] columnsMapping, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) addForeignKey(String foreignTable, String localColumn, String foreignColumn) addForeignKey(String name, String foreignTable, String[] columnsMapping) addForeignKey(String name, String foreignTable, String[] columnsMapping, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) addForeignKey(String name, String foreignTable, String localColumn, String foreignColumn) addForeignKey(String name, String foreignTable, String localColumn, String foreignColumn, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) addForeignKey(String foreignTable, String localColumn, String foreignColumn, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) addPrimaryKey(String column) addPrimaryKey(String[] columns) addPrimaryKey(String name, String column) addPrimaryKey(String name, String[] columns) alterColumnDefault(Class beanClass, String propertyName, Object value) alterColumnDefault(String name, boolean value) alterColumnDefault(String name, Object value) alterColumnDefaultFunction(String name, String defaultFunction) alterColumnNullable(Class beanClass, String propertyName, CreateTable.Nullable nullable) alterColumnNullable(String name, CreateTable.Nullable nullable) alterColumnType(Class beanClass, String propertyName) alterColumnType(String name, Class type) alterColumnType(String name, Class type, int precision) alterColumnType(String name, Class type, int precision, int scale) alterColumnType(String name, Class type, int precision, int scale, String typeAttribute) alterColumnType(String name, Class type, int precision, int scale, String typeAttribute, CreateTable.Nullable nullable) alterColumnType(String name, Class type, int precision, int scale, CreateTable.Nullable nullable) alterColumnType(String name, Class type, int precision, String typeAttribute) alterColumnType(String name, Class type, int precision, String typeAttribute, CreateTable.Nullable nullable) alterColumnType(String name, Class type, int precision, CreateTable.Nullable nullable) alterColumnType(String name, Class type, String typeAttribute) alterColumnType(String name, Class type, String typeAttribute, CreateTable.Nullable nullable) alterColumnType(String name, Class type, CreateTable.Nullable nullable) alterColumnType(String name, String customType) alterColumnType(String name, String customType, CreateTable.Nullable nullable) voidclear()protected voidclone()customAttribute(String name, String attribute) defaultFunction(String name, String defaultFunction) defaultValue(String name, boolean value) defaultValue(String name, Object value) dropColumn(Class beanClass, String propertyName) dropColumn(String name) dropColumnDefault(Class beanClass, String propertyName) dropColumnDefault(String name) dropConstraint(String name) rife.database.capabilities.CapabilitiesgetSql()getTable()nullable(String name, CreateTable.Nullable nullable) renameColumn(String name, String newName) voidsetExcludeUnsupportedCapabilities(boolean flag) toString()
-
Field Details
-
NULL
-
NOTNULL
-
NOACTION
-
RESTRICT
-
CASCADE
-
SETNULL
-
SETDEFAULT
-
datasource_
-
sql_
-
excludeUnsupportedCapabilities_
protected boolean excludeUnsupportedCapabilities_
-
-
Constructor Details
-
AlterTable
-
-
Method Details
-
clear
public void clear() -
getCapabilities
public rife.database.capabilities.Capabilities getCapabilities()- Specified by:
getCapabilitiesin interfaceQuery
-
getTable
-
getAlteration
-
getColumnName
-
getNewName
-
getConstraintName
-
getNullable
-
getDefault
-
getColumn
-
getPrimaryKey
-
getForeignKey
-
getUniqueConstraint
-
getCheckConstraint
-
table
-
addColumn
-
addColumn
-
addColumn
-
addColumn
-
addColumn
-
addColumn
public AlterTable addColumn(String name, Class type, int precision, int scale, String typeAttribute) -
addColumn
-
addColumn
public AlterTable addColumn(String name, Class type, String typeAttribute, CreateTable.Nullable nullable) -
addColumn
-
addColumn
public AlterTable addColumn(String name, Class type, int precision, String typeAttribute, CreateTable.Nullable nullable) -
addColumn
public AlterTable addColumn(String name, Class type, int precision, int scale, CreateTable.Nullable nullable) -
addColumn
public AlterTable addColumn(String name, Class type, int precision, int scale, String typeAttribute, CreateTable.Nullable nullable) -
addColumn
-
addColumn
-
addColumn
- Throws:
DbQueryException
-
precision
-
precision
-
nullable
-
defaultValue
-
defaultValue
-
defaultFunction
-
customAttribute
-
dropColumn
-
dropColumn
-
renameColumn
-
alterColumnType
-
alterColumnType
-
alterColumnType
-
alterColumnType
-
alterColumnType
-
alterColumnType
public AlterTable alterColumnType(String name, Class type, int precision, int scale, String typeAttribute) -
alterColumnType
-
alterColumnType
public AlterTable alterColumnType(String name, Class type, String typeAttribute, CreateTable.Nullable nullable) -
alterColumnType
public AlterTable alterColumnType(String name, Class type, int precision, CreateTable.Nullable nullable) -
alterColumnType
public AlterTable alterColumnType(String name, Class type, int precision, String typeAttribute, CreateTable.Nullable nullable) -
alterColumnType
public AlterTable alterColumnType(String name, Class type, int precision, int scale, CreateTable.Nullable nullable) -
alterColumnType
public AlterTable alterColumnType(String name, Class type, int precision, int scale, String typeAttribute, CreateTable.Nullable nullable) -
alterColumnType
-
alterColumnType
-
alterColumnType
-
alterColumnNullable
-
alterColumnNullable
public AlterTable alterColumnNullable(Class beanClass, String propertyName, CreateTable.Nullable nullable) -
alterColumnDefault
-
alterColumnDefault
-
alterColumnDefaultFunction
-
alterColumnDefault
-
dropColumnDefault
-
dropColumnDefault
-
addPrimaryKey
-
addPrimaryKey
-
addPrimaryKey
-
addPrimaryKey
-
addForeignKey
-
addForeignKey
public AlterTable addForeignKey(String foreignTable, String localColumn, String foreignColumn, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) -
addForeignKey
-
addForeignKey
public AlterTable addForeignKey(String foreignTable, String[] columnsMapping, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) -
addForeignKey
public AlterTable addForeignKey(String name, String foreignTable, String localColumn, String foreignColumn) -
addForeignKey
public AlterTable addForeignKey(String name, String foreignTable, String localColumn, String foreignColumn, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) -
addForeignKey
-
addForeignKey
public AlterTable addForeignKey(String name, String foreignTable, String[] columnsMapping, CreateTable.ViolationAction onUpdate, CreateTable.ViolationAction onDelete) -
addUnique
-
addUnique
-
addUnique
-
addUnique
-
addCheck
-
addCheck
-
dropConstraint
-
dropPrimaryKey
-
renameTo
-
getSql
- Specified by:
getSqlin interfaceQuery- Throws:
DbQueryException
-
clone
-
getDatasource
-
getParameters
- Specified by:
getParametersin interfaceQuery
-
setExcludeUnsupportedCapabilities
public void setExcludeUnsupportedCapabilities(boolean flag) - Specified by:
setExcludeUnsupportedCapabilitiesin interfaceQuery
-
clearGenerated
protected void clearGenerated() -
toString
-