Package org.h2.command.ddl
Class AlterTableAlterColumn
- java.lang.Object
-
- org.h2.command.Prepared
-
- org.h2.command.ddl.DefineCommand
-
- org.h2.command.ddl.SchemaCommand
-
- org.h2.command.ddl.CommandWithColumns
-
- org.h2.command.ddl.AlterTableAlterColumn
-
public class AlterTableAlterColumn extends CommandWithColumns
This class represents the statements ALTER TABLE ADD, ALTER TABLE ADD IF NOT EXISTS, ALTER TABLE ALTER COLUMN, ALTER TABLE ALTER COLUMN SELECTIVITY, ALTER TABLE ALTER COLUMN SET DEFAULT, ALTER TABLE ALTER COLUMN DROP DEFAULT, ALTER TABLE ALTER COLUMN DROP EXPRESSION, ALTER TABLE ALTER COLUMN SET NULL, ALTER TABLE ALTER COLUMN DROP NULL, ALTER TABLE ALTER COLUMN SET VISIBLE, ALTER TABLE ALTER COLUMN SET INVISIBLE, ALTER TABLE DROP COLUMN
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
addAfter
private java.lang.String
addBefore
private boolean
addFirst
private boolean
booleanFlag
private java.util.ArrayList<Column>
columnsToAdd
private java.util.ArrayList<Column>
columnsToRemove
private Expression
defaultExpression
Default or on update expression.private boolean
ifNotExists
private boolean
ifTableExists
private Column
newColumn
private Expression
newSelectivity
private Column
oldColumn
private java.lang.String
tableName
private int
type
private Expression
usingExpression
-
Fields inherited from class org.h2.command.ddl.DefineCommand
transactional
-
Fields inherited from class org.h2.command.Prepared
create, parameters, prepareAlways, session, sqlStatement, sqlTokens
-
-
Constructor Summary
Constructors Constructor Description AlterTableAlterColumn(SessionLocal session, Schema schema)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(Column column)
Add a column to this table.private static java.lang.StringBuilder
addColumn(Column column, java.lang.StringBuilder columnNames, java.lang.StringBuilder columnValues)
private void
checkClustering(Column c)
private static void
checkDefaultReferencesTable(Table table, Expression defaultExpression)
private void
checkNoNullValues(Table table)
private void
checkNullable(Table table)
private void
checkViews(SchemaObject sourceTable, SchemaObject newTable)
Check that all views and other dependent objects.private void
checkViewsAreValid(DbObject tableOrView)
Check that a table or view is still valid.private Table
cloneTableStructure(Table table, Column[] columns, Database db, java.lang.String tempName, java.util.ArrayList<Column> newColumns)
private void
convertIdentityColumn(Table table, Column c)
private void
copyData(Table table, java.util.ArrayList<Sequence> sequences, boolean createConstraints)
private void
execute(java.lang.String sql)
int
getType()
Get the command type as defined in CommandInterfaceprivate void
removeSequence(Table table, Sequence sequence)
void
setAddAfter(java.lang.String after)
void
setAddBefore(java.lang.String before)
void
setAddFirst()
Add the column as the first column of the table.void
setBooleanFlag(boolean booleanFlag)
void
setColumnsToRemove(java.util.ArrayList<Column> columnsToRemove)
void
setDefaultExpression(Expression defaultExpression)
Set default or on update expression.void
setIfNotExists(boolean ifNotExists)
void
setIfTableExists(boolean b)
void
setNewColumn(Column newColumn)
void
setOldColumn(Column oldColumn)
void
setSelectivity(Expression selectivity)
void
setTableName(java.lang.String tableName)
void
setType(int type)
void
setUsingExpression(Expression usingExpression)
Set using expression.long
update()
Execute the statement.-
Methods inherited from class org.h2.command.ddl.CommandWithColumns
addConstraintCommand, changePrimaryKeysToNotNull, createConstraints, generateSequences, getPrimaryKey
-
Methods inherited from class org.h2.command.ddl.SchemaCommand
getSchema
-
Methods inherited from class org.h2.command.ddl.DefineCommand
isReadOnly, isTransactional, queryMeta, setTransactional
-
Methods inherited from class org.h2.command.Prepared
checkCanceled, checkParameters, collectDependencies, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getPlanSQL, getSession, getSimpleSQL, getSQL, getSQLTokens, isCacheable, isQuery, needRecompile, prepare, query, setCommand, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString
-
-
-
-
Field Detail
-
tableName
private java.lang.String tableName
-
oldColumn
private Column oldColumn
-
newColumn
private Column newColumn
-
type
private int type
-
defaultExpression
private Expression defaultExpression
Default or on update expression.
-
newSelectivity
private Expression newSelectivity
-
usingExpression
private Expression usingExpression
-
addFirst
private boolean addFirst
-
addBefore
private java.lang.String addBefore
-
addAfter
private java.lang.String addAfter
-
ifTableExists
private boolean ifTableExists
-
ifNotExists
private boolean ifNotExists
-
columnsToAdd
private java.util.ArrayList<Column> columnsToAdd
-
columnsToRemove
private java.util.ArrayList<Column> columnsToRemove
-
booleanFlag
private boolean booleanFlag
-
-
Constructor Detail
-
AlterTableAlterColumn
public AlterTableAlterColumn(SessionLocal session, Schema schema)
-
-
Method Detail
-
setIfTableExists
public void setIfTableExists(boolean b)
-
setTableName
public void setTableName(java.lang.String tableName)
-
setOldColumn
public void setOldColumn(Column oldColumn)
-
setAddFirst
public void setAddFirst()
Add the column as the first column of the table.
-
setAddBefore
public void setAddBefore(java.lang.String before)
-
setAddAfter
public void setAddAfter(java.lang.String after)
-
update
public long update()
Description copied from class:Prepared
Execute the statement.
-
checkDefaultReferencesTable
private static void checkDefaultReferencesTable(Table table, Expression defaultExpression)
-
checkClustering
private void checkClustering(Column c)
-
copyData
private void copyData(Table table, java.util.ArrayList<Sequence> sequences, boolean createConstraints)
-
cloneTableStructure
private Table cloneTableStructure(Table table, Column[] columns, Database db, java.lang.String tempName, java.util.ArrayList<Column> newColumns)
-
addColumn
private static java.lang.StringBuilder addColumn(Column column, java.lang.StringBuilder columnNames, java.lang.StringBuilder columnValues)
-
checkViews
private void checkViews(SchemaObject sourceTable, SchemaObject newTable)
Check that all views and other dependent objects.
-
checkViewsAreValid
private void checkViewsAreValid(DbObject tableOrView)
Check that a table or view is still valid.- Parameters:
tableOrView
- the table or view to check
-
execute
private void execute(java.lang.String sql)
-
checkNullable
private void checkNullable(Table table)
-
checkNoNullValues
private void checkNoNullValues(Table table)
-
setType
public void setType(int type)
-
setSelectivity
public void setSelectivity(Expression selectivity)
-
setDefaultExpression
public void setDefaultExpression(Expression defaultExpression)
Set default or on update expression.- Parameters:
defaultExpression
- default or on update expression
-
setUsingExpression
public void setUsingExpression(Expression usingExpression)
Set using expression.- Parameters:
usingExpression
- using expression
-
setNewColumn
public void setNewColumn(Column newColumn)
-
getType
public int getType()
Description copied from class:Prepared
Get the command type as defined in CommandInterface
-
setIfNotExists
public void setIfNotExists(boolean ifNotExists)
-
addColumn
public void addColumn(Column column)
Description copied from class:CommandWithColumns
Add a column to this table.- Specified by:
addColumn
in classCommandWithColumns
- Parameters:
column
- the column to add
-
setColumnsToRemove
public void setColumnsToRemove(java.util.ArrayList<Column> columnsToRemove)
-
setBooleanFlag
public void setBooleanFlag(boolean booleanFlag)
-
-