Package gudusoft.gsqlparser.nodes
Class TConstraint
Object
gudusoft.gsqlparser.nodes.TParseTreeNode
gudusoft.gsqlparser.nodes.TConstraint
- All Implemented Interfaces:
Visitable,Iterator<TSourceToken>
Use a constraint to define an integrity constraint, a rule that restricts the values in a database.
Oracle Database lets you create six types of constraints and lets you declare them in two ways.
- A NOT NULL constraint prohibits a database value from being null.
- A unique constraint prohibits multiple rows from having the same value in the same column or combination of columns but allows some values to be null.
call method
getColumnList()to result columns of this unique key. - A primary key constraint combines a NOT NULL constraint and a unique
constraint in a single declaration. It prohibits multiple rows from having the same
value in the same column or combination of columns and prohibits values from being null.
call method
getColumnList()to result columns of this primary key. - A foreign key constraint requires values in one table to match values in another table.
call method
getColumnList()to result columns of this foreign key. - A check constraint requires a value in the database to comply with a specified condition.
call method
getCheckCondition()to return this condition. - A REF column by definition references an object in another object type or in a relational table. A REF constraint lets you further describe the relationship between the REF column and the object it references.
- default constraint is valid in sql server.
-
Field Summary
Fields inherited from class gudusoft.gsqlparser.nodes.TParseTreeNode
dbvendor, doubleLinkedTokenListToString, nodeActionAppend, nodeActionInsert, nodeActionRemove, nodeActionUnknown, nodeActionUpdate, nodeActionUpdateText, nodeChangeEndToken, nodeChangeStartToken -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAccept a visitorvoidAccept a visitor to iterate this class and sub-nodes of this classvoiddoParse(TCustomSqlStatement psql, ESqlClause plocation) Analyze the sub-nodes inside this node.intUsed internalDeprecated.Snowflake index table constraint: CREATE TABLE t1 (c1 INT, c2 INT, CONSTRAINT c1_idx INDEX (c1));SQL Server, index name of table index whengetConstraint_type()isEConstraintType.table_indexor index name of column index whengetConstraint_type()isEConstraintType.column_indexgetSeed()Used internalvoidInitialize a query tree node.voidvoidbooleanbooleanvoidsetAutomaticProperties(TPTNodeList<TAutomaticProperty> automaticProperties) voidsetCheckCondition(TExpression checkCondition) voidsetClustered(boolean clustered) voidsetClusteredToken(TSourceToken clusteredToken) voidsetColumnGeneratedClause(TColumnGeneratedClause columnGeneratedClause) voidsetColumnList(TPTNodeList<TColumnWithSortOrder> columnList) voidsetCommentObject(TObjectName commentObject) voidsetConstraint_type(EConstraintType constraint_type) voidsetConstraintLevel(int constraintLevel) voidsetConstraintName(TObjectName constraintName) voidsetDefaultExpression(TExpression defaultExpression) voidsetForObjectName(TObjectName forObjectName) voidsetIncrement(TExpression increment) voidsetIndexCols(TPTNodeList<TIndexColName> indexCols) voidsetKeyActions(TPTNodeList<TKeyAction> keyActions) voidsetNonClustered(boolean nonClustered) voidsetOnFilegroup(TDummy onFilegroup) voidsetReferencedColumnList(TObjectNameList referencedColumnList) voidsetReferencedObject(TObjectName referencedObject) voidsetSeed(TExpression seed) voidsetWithIndexoption(TDummy withIndexoption) Methods inherited from class gudusoft.gsqlparser.nodes.TParseTreeNode
addAllMyTokensToTokenList, addToTokenChain, appendNewNode, calculateTokenCount, doAppendNewNode, fastSetString, getAnchorNode, getColumnNo, getCommentAfterNode, getCommentBeforeNode, getCompactString, getDummyTag, getEndToken, getEvaluateDatatype, getEvalValue, getGsqlparser, getLineNo, getLocation, getMd5, getNodeStatus, getNodeType, getParentObjectName, getPlainText, getStartToken, getTokenCount, hasNext, init, init, init, insertAfterAToken, insertNewNodeBeforeMe, isChanged, isTokensInChain, next, refreshAllNodesTokenCount, remove, removeAllMyTokensFromTokenList, removeTokens, removeTokensBetweenNodes, removeTokensBetweenToken, replaceWithNewNode, resetIterator, setAnchorNode, setChanged, setDummyTag, setEndToken, setEndToken, setEndToken, setEndToken, setEndToken, setEndTokenDirectly, setEvaluateDatatype, setEvalValue, setGsqlparser, setIncludingComment, setLocation, setNewSubNode, setNodeStatus, setNodeType, setParent, setPlainText, setStartToken, setStartToken, setStartToken, setStartToken, setStartTokenDirectly, setString, setString2, subNodeInNode, toScript, toString, toString2Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
TConstraint
public TConstraint()
-
-
Method Details
-
setColumnGeneratedClause
-
getColumnGeneratedClause
-
setOnFilegroup
-
getOnFilegroup
-
setWithIndexoption
-
getWithIndexoption
-
getIndexName
SQL Server, index name of table index whengetConstraint_type()isEConstraintType.table_indexor index name of column index whengetConstraint_type()isEConstraintType.column_index- Returns:
- index name
-
setCommentObject
-
setForObjectName
-
getForObjectName
-
getCommentObject
-
setKeyActions
-
getKeyActions
-
setConstraintLevel
-
getConstraintLevel
- Returns:
- is this a columnn level constraint or table level constraint TBaseType.constraint_level_table or TBaseType.constraint_level_column.
-
setDefaultExpression
-
getDefaultExpression
- Returns:
- default expression of sql server.
-
setConstraintName
-
getConstraintName
- Returns:
- name for the constraint, it's optional.
-
setConstraint_type
-
getConstraint_type
- Returns:
- type of constraints.
- See Also:
-
setClustered
-
setClusteredToken
-
isClustered
-
isNonClustered
-
setNonClustered
-
setAutomaticProperties
-
getAutomaticProperties
- Returns:
- Automatic Initialization and Updating for TIMESTAMP in MySQL
-
getCheckCondition
- Returns:
- used in check constraint, requires a value in the database to comply with this specified condition.
-
getColumnList
- Returns:
- column name list used when constraint type is unique, primary key or foreign key.
-
setColumnList
-
getIndexCols
Deprecated.since 1.8.7.2, usegetColumnList()instead.- Returns:
-
init
Description copied from class:TParseTreeNodeInitialize a query tree node. Used internally- Overrides:
initin classTParseTreeNode- Parameters:
arg1- first argument
-
getIndexColumnName
Snowflake index table constraint: CREATE TABLE t1 (c1 INT, c2 INT, CONSTRAINT c1_idx INDEX (c1));- Returns:
-
init
- Overrides:
initin classTParseTreeNode
-
init
- Overrides:
initin classTParseTreeNode
-
setReferencedColumnList
-
getReferencedColumnList
- Returns:
- column name list of referenced object in reference clause when constraint type is REF constraint.
-
setReferencedObject
-
getReferencedObject
- Returns:
- referenced object in reference clause when constraint type is REF constraint.
-
setIncrement
-
setSeed
-
getIncrement
Used internal- Returns:
-
getSeed
Used internal- Returns:
-
accept
Description copied from class:TParseTreeNodeAccept a visitor- Specified by:
acceptin interfaceVisitable- Overrides:
acceptin classTParseTreeNode- Parameters:
v- visitor is a descendant class ofTParseTreeVisitor
-
acceptChildren
Description copied from class:TParseTreeNodeAccept a visitor to iterate this class and sub-nodes of this class- Specified by:
acceptChildrenin interfaceVisitable- Overrides:
acceptChildrenin classTParseTreeNode- Parameters:
v- visitor is a descendant class ofTParseTreeVisitor
-
doParse
Description copied from class:TParseTreeNodeAnalyze the sub-nodes inside this node. Such as build the relationship between table and column.- Overrides:
doParsein classTParseTreeNode- Parameters:
psql- SQL statement this node belongs toplocation- SQL clause this node belongs to
-
setCheckCondition
-
setIndexCols
-
getColumnList()instead.