Top Description Fields Constructors Methods
org.h2.command.ddl

public Class AlterTableAddConstraint

extends AlterTable
Class Inheritance
Imports
java.util.ArrayList, org.h2.api.ErrorCode, org.h2.command.CommandInterface, org.h2.constraint.Constraint, .ConstraintActionType, .ConstraintCheck, .ConstraintReferential, .ConstraintUnique, org.h2.engine.Constants, .Database, .Right, .SessionLocal, .NullsDistinct, org.h2.expression.Expression, org.h2.index.Index, .IndexType, org.h2.message.DbException, org.h2.schema.Schema, org.h2.table.Column, .IndexColumn, .Table, .TableFilter, org.h2.util.HasSQL, org.h2.value.DataType

This class represents the statement ALTER TABLE ADD CONSTRAINT

Field Summary

Modifier and TypeField and Description
private boolean
private Expression
private String
private String
private final ArrayList<Index>
private ConstraintUnique
private ConstraintActionType
private final boolean
private Index
private IndexColumn[]
private NullsDistinct
private boolean
private Index
private IndexColumn[]
private Schema
private String
private final int
private ConstraintActionType
Inherited from org.h2.command.ddl.AlterTable:
ifTableExiststableName

Constructor Summary

AccessConstructor and Description
public
AlterTableAddConstraint(SessionLocal session, Schema schema, int type, boolean ifNotExists)

Method Summary

Modifier and TypeMethod and Description
private void
private static boolean
canUseIndex(Index index, Table table, IndexColumn[] cols, NullsDistinct nullsDistinct)

private Index
createIndex(Table t, IndexColumn[] cols, NullsDistinct nullsDistinct)

private ConstraintUnique
createUniqueConstraint(Table table, Index index, IndexColumn[] indexColumns, boolean forForeignKey)

private String
public String
private static Index
getIndex(Table t, IndexColumn[] cols, NullsDistinct nullsDistinct)

public IndexColumn[]
public int
getType()

Implements abstract org.h2.command.Prepared.getType.

Get the command type as defined in CommandInterface

private static ConstraintUnique
public void
setCheckExisting(boolean b)

public void
public void
setComment(String comment)

public void
setConstraintName(String constraintName)

public void
public void
setIndex(Index index)

public void
setIndexColumns(IndexColumn[] indexColumns)

public void
public void
setPrimaryKeyHash(boolean b)

public void
setRefIndex(Index refIndex)

public void
public void
setRefTableName(Schema
the schema
refSchema
,
String
the table name
ref
)

Set the referenced table.

public void
private int

Returns:

the update count
tryUpdate
(Table table)

Try to execute the statement.

public long
Inherited from org.h2.command.ddl.AlterTable:
setIfTableExistssetTableNameupdate

Field Detail

checkExistingback to summary
private boolean checkExisting
checkExpressionback to summary
private Expression checkExpression
commentback to summary
private String comment
constraintNameback to summary
private String constraintName
createdIndexesback to summary
private final ArrayList<Index> createdIndexes
createdUniqueConstraintback to summary
private ConstraintUnique createdUniqueConstraint
deleteActionback to summary
private ConstraintActionType deleteAction
ifNotExistsback to summary
private final boolean ifNotExists
indexback to summary
private Index index
indexColumnsback to summary
private IndexColumn[] indexColumns
nullsDistinctback to summary
private NullsDistinct nullsDistinct
primaryKeyHashback to summary
private boolean primaryKeyHash
refIndexback to summary
private Index refIndex
refIndexColumnsback to summary
private IndexColumn[] refIndexColumns
refSchemaback to summary
private Schema refSchema
refTableNameback to summary
private String refTableName
typeback to summary
private final int type
updateActionback to summary
private ConstraintActionType updateAction

Constructor Detail

AlterTableAddConstraintback to summary
public AlterTableAddConstraint(SessionLocal session, Schema schema, int type, boolean ifNotExists)

Method Detail

addConstraintToTableback to summary
private void addConstraintToTable(Database db, Table table, Constraint constraint)
canUseIndexback to summary
private static boolean canUseIndex(Index index, Table table, IndexColumn[] cols, NullsDistinct nullsDistinct)
createIndexback to summary
private Index createIndex(Table t, IndexColumn[] cols, NullsDistinct nullsDistinct)
createUniqueConstraintback to summary
private ConstraintUnique createUniqueConstraint(Table table, Index index, IndexColumn[] indexColumns, boolean forForeignKey)
generateConstraintNameback to summary
private String generateConstraintName(Table table)
getConstraintNameback to summary
public String getConstraintName()
getIndexback to summary
private static Index getIndex(Table t, IndexColumn[] cols, NullsDistinct nullsDistinct)
getIndexColumnsback to summary
public IndexColumn[] getIndexColumns()
getTypeback to summary
public int getType()

Implements abstract org.h2.command.Prepared.getType.

Doc from org.h2.command.Prepared.getType.

Get the command type as defined in CommandInterface

Returns:int

the statement type

Annotations
@Override
getUniqueConstraintback to summary
private static ConstraintUnique getUniqueConstraint(Table t, IndexColumn[] cols)
setCheckExistingback to summary
public void setCheckExisting(boolean b)
setCheckExpressionback to summary
public void setCheckExpression(Expression expression)
setCommentback to summary
public void setComment(String comment)
setConstraintNameback to summary
public void setConstraintName(String constraintName)
setDeleteActionback to summary
public void setDeleteAction(ConstraintActionType action)
setIndexback to summary
public void setIndex(Index index)
setIndexColumnsback to summary
public void setIndexColumns(IndexColumn[] indexColumns)
setNullsDistinctback to summary
public void setNullsDistinct(NullsDistinct nullsDistinct)
setPrimaryKeyHashback to summary
public void setPrimaryKeyHash(boolean b)
setRefIndexback to summary
public void setRefIndex(Index refIndex)
setRefIndexColumnsback to summary
public void setRefIndexColumns(IndexColumn[] indexColumns)
setRefTableNameback to summary
public void setRefTableName(Schema refSchema, String ref)

Set the referenced table.

Parameters
refSchema:Schema

the schema

ref:String

the table name

setUpdateActionback to summary
public void setUpdateAction(ConstraintActionType action)
tryUpdateback to summary
private int tryUpdate(Table table)

Try to execute the statement.

Returns:int

the update count

updateback to summary
public long update(Table table)

Implements abstract org.h2.command.ddl.AlterTable.update.

Annotations
@Override