Top Description Fields Constructors Methods
org.h2.index

public Class IndexType

extends Object
Class Inheritance
Imports
java.util.Objects, org.h2.engine.NullsDistinct

Represents information about the properties of an index

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private NullsDistinct
private boolean
private boolean
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IndexType

Returns:

the index type
createNonUnique
(boolean
if the index is persistent
persistent
)

Create a non-unique index.

public static IndexType

Returns:

the index type
createNonUnique
(boolean
if the index is persistent
persistent
,
boolean
if a hash index should be used
hash
,
boolean
if a spatial index should be used
spatial
)

Create a non-unique index.

public static IndexType

Returns:

the index type
createPrimaryKey
(boolean
if the index is persistent
persistent
,
boolean
if a hash index should be used
hash
)

Create a primary key index.

public static IndexType

Returns:

the index type
createScan
(boolean
if the index is persistent
persistent
)

Create a scan pseudo-index.

public static IndexType

Returns:

the index type
createUnique
(boolean
if the index is persistent
persistent
,
boolean
if a hash index should be used
hash
,
int
count of unique columns (not stored)
uniqueColumnCount
,
NullsDistinct
are nulls distinct
nullsDistinct
)

Create a unique index.

public boolean

Returns:

if the index belongs to a constraint
getBelongsToConstraint
()

If the index is created because of a constraint.

public NullsDistinct

Returns:

are nulls distinct, or null for non-unique indexes
getEffectiveNullsDistinct
()

Returns nulls distinct treatment for unique indexes, NullsDistinct#NOT_DISTINCT for primary key indexes, and null for other types of indexes.

public NullsDistinct

Returns:

are nulls distinct, or null for non-unique and primary key indexes
getNullsDistinct
()

Returns nulls distinct treatment for unique indexes (excluding primary key indexes).

public String

Returns:

the SQL snippet
getSQL
(boolean
true to add nulls distinct clause
addNullsDistinct
)

Get the SQL snippet to create such an index.

public boolean

Returns:

true if it is a hash index
isHash
()

Is this a hash index?

public boolean

Returns:

true if it is persistent
isPersistent
()

Is this index persistent?

public boolean

Returns:

true if it references a primary key constraint
isPrimaryKey
()

Does this index belong to a primary key constraint?

public boolean

Returns:

true if it is
isScan
()

Is this a table scan pseudo-index?

public boolean

Returns:

true if it is a spatial index
isSpatial
()

Is this a spatial index?

public boolean

Returns:

true if it is
isUnique
()

Is this a unique index?

public void
setBelongsToConstraint(boolean
if the index belongs to a constraint
belongsToConstraint
)

Sets if this index belongs to a constraint.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

belongsToConstraintback to summary
private boolean belongsToConstraint
hashback to summary
private boolean hash
nullsDistinctback to summary
private NullsDistinct nullsDistinct
persistentback to summary
private boolean persistent
primaryKeyback to summary
private boolean primaryKey
scanback to summary
private boolean scan
spatialback to summary
private boolean spatial

Constructor Detail

IndexTypeback to summary
public IndexType()

Method Detail

createNonUniqueback to summary
public static IndexType createNonUnique(boolean persistent)

Create a non-unique index.

Parameters
persistent:boolean

if the index is persistent

Returns:IndexType

the index type

createNonUniqueback to summary
public static IndexType createNonUnique(boolean persistent, boolean hash, boolean spatial)

Create a non-unique index.

Parameters
persistent:boolean

if the index is persistent

hash:boolean

if a hash index should be used

spatial:boolean

if a spatial index should be used

Returns:IndexType

the index type

createPrimaryKeyback to summary
public static IndexType createPrimaryKey(boolean persistent, boolean hash)

Create a primary key index.

Parameters
persistent:boolean

if the index is persistent

hash:boolean

if a hash index should be used

Returns:IndexType

the index type

createScanback to summary
public static IndexType createScan(boolean persistent)

Create a scan pseudo-index.

Parameters
persistent:boolean

if the index is persistent

Returns:IndexType

the index type

createUniqueback to summary
public static IndexType createUnique(boolean persistent, boolean hash, int uniqueColumnCount, NullsDistinct nullsDistinct)

Create a unique index.

Parameters
persistent:boolean

if the index is persistent

hash:boolean

if a hash index should be used

uniqueColumnCount:int

count of unique columns (not stored)

nullsDistinct:NullsDistinct

are nulls distinct

Returns:IndexType

the index type

getBelongsToConstraintback to summary
public boolean getBelongsToConstraint()

If the index is created because of a constraint. Such indexes are to be dropped once the constraint is dropped.

Returns:boolean

if the index belongs to a constraint

getEffectiveNullsDistinctback to summary
public NullsDistinct getEffectiveNullsDistinct()

Returns nulls distinct treatment for unique indexes, NullsDistinct#NOT_DISTINCT for primary key indexes, and null for other types of indexes.

Returns:NullsDistinct

are nulls distinct, or null for non-unique indexes

getNullsDistinctback to summary
public NullsDistinct getNullsDistinct()

Returns nulls distinct treatment for unique indexes (excluding primary key indexes). For primary key and other types of indexes returns null.

Returns:NullsDistinct

are nulls distinct, or null for non-unique and primary key indexes

getSQLback to summary
public String getSQL(boolean addNullsDistinct)

Get the SQL snippet to create such an index.

Parameters
addNullsDistinct:boolean

true to add nulls distinct clause

Returns:String

the SQL snippet

isHashback to summary
public boolean isHash()

Is this a hash index?

Returns:boolean

true if it is a hash index

isPersistentback to summary
public boolean isPersistent()

Is this index persistent?

Returns:boolean

true if it is persistent

isPrimaryKeyback to summary
public boolean isPrimaryKey()

Does this index belong to a primary key constraint?

Returns:boolean

true if it references a primary key constraint

isScanback to summary
public boolean isScan()

Is this a table scan pseudo-index?

Returns:boolean

true if it is

isSpatialback to summary
public boolean isSpatial()

Is this a spatial index?

Returns:boolean

true if it is a spatial index

isUniqueback to summary
public boolean isUnique()

Is this a unique index?

Returns:boolean

true if it is

setBelongsToConstraintback to summary
public void setBelongsToConstraint(boolean belongsToConstraint)

Sets if this index belongs to a constraint.

Parameters
belongsToConstraint:boolean

if the index belongs to a constraint