Whereas non-deferrable constraints are backed by UNIQUE indexes, deferrable constraints are backed by non-unique indexes. The duplicate checking on inserts and updates for deferrable constraints are handled at the language level, not by the store level. The following table shows the correspondence between the constraint types and the index attributes used:
\ Value | Number of index columns | Check
Attribute \ | in physical BTree key | in
--------------------------------------------------------------------
unique | true | N - 1 (row location |
isUniqueWithDuplicateNulls | false | not part of key) | Store
uniqueDeferrable | false | | Btree
hasDeferrableChecking | false | | code
\ Value | Number of index columns | Check
Attribute \ | in physical BTree key | in
------------------------------------------------------------ -------
unique | false | N |
isUniqueWithDuplicateNulls | true | | Store
uniqueDeferrable | false | | Btree
hasDeferrableChecking | false | | code
\ Value | Number of index columns | Check
Attribute \ | in physical BTree key | in
------------------------------------------------------------ -------
unique | false | N |
isUniqueWithDuplicateNulls | false | | Lang.
uniqueDeferrable | true | | code
hasDeferrableChecking | true | |
\ Value | Number of index columns | Check
Attribute \ | in physical BTree key | in
------------------------------------------------------------ -------
unique | false | N |
isUniqueWithDuplicateNulls | true | | Lang.
uniqueDeferrable | false | | code
hasDeferrableChecking | true | |
| Modifier and Type | Method and Description |
|---|---|
| public int[] | Returns: an array of column positions in the base tableReturns an array of column positions in the base table. |
| public int | Returns: the position of the column in the keyPosition of column in heap row heapColumnPosition)Returns the postion of a column. |
| public boolean | Returns: true if the index is used to support a deferrable constraintReturns true if the index is used to support a deferrable constraint. |
| public String | |
| public boolean[] | Returns: array of boolean telling asc/desc info for each index keyReturns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method. |
| public boolean | Returns: true if the specified column is ascending in the indexKey column number keyColumnPosition)Returns true if the specified column is ascending in the index (1-based). |
| public boolean | Returns: true if the specified column is descending in the indexKey column number keyColumnPosition)Returns true if the specified column is descending in the index (1-based). |
| public boolean | |
| public boolean | Returns: true if the index represents such a constraintThe index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable. |
| public boolean | Returns: true if the index is duplicate keys only for null key partsReturns true if the index is duplicate keys only for null key parts. |
| public int | Returns: the number of ordered columnsReturns the number of ordered columns. |
| public void | setBaseColumnPositions(int[]
Positions of base columns baseColumnPositions)set the baseColumnPositions field of the index descriptor. |
| public void | setIsAscending(boolean[]
Set the direction of each column in the key isAscending)set the isAscending field of the index descriptor. |
| public void | setNumberOfOrderedColumns(int
Number of ordered columns numberOfOrderedColumns)set the numberOfOrderedColumns field of the index descriptor. |
| baseColumnPositions | back to summary |
|---|---|
| public int[] baseColumnPositions() Returns an array of column positions in the base table. Each index column corresponds to a column position in the base table, except the column representing the location of the row in the base table. The returned array holds the column positions in the base table, so, if entry 2 is the number 4, the second column in the index is the fourth column in the table.
| |
| getKeyColumnPosition | back to summary |
|---|---|
| public int getKeyColumnPosition(int heapColumnPosition) Returns the postion of a column. Returns the position of a column within the key (1-based). 0 means that the column is not in the key. Same as the above method, but it uses int instead of Integer.
| |
| hasDeferrableChecking | back to summary |
|---|---|
| public boolean hasDeferrableChecking() Returns true if the index is used to support a deferrable constraint.
| |
| indexType | back to summary |
|---|---|
| public String indexType() Returns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.
| |
| isAscending | back to summary |
|---|---|
| public boolean[] isAscending() Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method. Both methods return an array with subscript starting from 0.
| |
| isAscending | back to summary |
|---|---|
| public boolean isAscending(Integer keyColumnPosition) Returns true if the specified column is ascending in the index (1-based).
| |
| isDescending | back to summary |
|---|---|
| public boolean isDescending(Integer keyColumnPosition) Returns true if the specified column is descending in the index (1-based). In the current release, only ascending columns are supported.
| |
| isUnique | back to summary |
|---|---|
| public boolean isUnique() Returns true if the index is unique.
| |
| isUniqueDeferrable | back to summary |
|---|---|
| public boolean isUniqueDeferrable() The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which
is deferrable.
| |
| isUniqueWithDuplicateNulls | back to summary |
|---|---|
| public boolean isUniqueWithDuplicateNulls() Returns true if the index is duplicate keys only for null key parts. This is effective only if isUnique is false.
| |
| numberOfOrderedColumns | back to summary |
|---|---|
| public int numberOfOrderedColumns() Returns the number of ordered columns. In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries. The ordered columns will be at the beginning of the index row, and they will be followed by the non-ordered columns. For now, all columns in an index must be ordered.
| |
| setBaseColumnPositions | back to summary |
|---|---|
| public void setBaseColumnPositions(int[] baseColumnPositions) set the baseColumnPositions field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where baseColumnPositions is changed.
| |
| setIsAscending | back to summary |
|---|---|
| public void setIsAscending(boolean[] isAscending) set the isAscending field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where isAscending is changed.
| |
| setNumberOfOrderedColumns | back to summary |
|---|---|
| public void setNumberOfOrderedColumns(int numberOfOrderedColumns) set the numberOfOrderedColumns field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where numberOfOrderedColumns is changed.
| |