org.h2.index

## Class IndexType

- java.lang.Object
- - org.h2.index.IndexType

    public class IndexType
    extends java.lang.Object

Represents information about the properties of an index

### Constructor Summary

Constructors
Constructor and Description
`IndexType()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static IndexType` `createNonUnique(boolean persistent)` Create a non-unique index.
`static IndexType` `createNonUnique(boolean persistent, boolean hash, boolean spatial)` Create a non-unique index.
`static IndexType` `createPrimaryKey(boolean persistent, boolean hash)` Create a primary key index.
`static IndexType` `createScan(boolean persistent)` Create a scan pseudo-index.
`static IndexType` `createUnique(boolean persistent, boolean hash, int uniqueColumnCount, NullsDistinct nullsDistinct)` Create a unique index.
`boolean` `getBelongsToConstraint()` If the index is created because of a constraint.
`NullsDistinct` `getEffectiveNullsDistinct()` Returns nulls distinct treatment for unique indexes, `NullsDistinct.NOT_DISTINCT` for primary key indexes, and `null` for other types of indexes.
`NullsDistinct` `getNullsDistinct()` Returns nulls distinct treatment for unique indexes (excluding primary key indexes).
`java.lang.String` `getSQL(boolean addNullsDistinct)` Get the SQL snippet to create such an index.
`boolean` `isHash()` Is this a hash index?
`boolean` `isPersistent()` Is this index persistent?
`boolean` `isPrimaryKey()` Does this index belong to a primary key constraint?
`boolean` `isScan()` Is this a table scan pseudo-index?
`boolean` `isSpatial()` Is this a spatial index?
`boolean` `isUnique()` Is this a unique index?
`void` `setBelongsToConstraint(boolean belongsToConstraint)` Sets if this index belongs to a constraint.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IndexType

    public IndexType()

### Method Detail

#### createPrimaryKey

    public static IndexType createPrimaryKey(boolean persistent,
                                             boolean hash)

Create a primary key index.

Parameters:
  `persistent` - if the index is persistent
  `hash` - if a hash index should be used
Returns:
  the index type

#### createUnique

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

Create a unique index.

Parameters:
  `persistent` - if the index is persistent
  `hash` - if a hash index should be used
  `uniqueColumnCount` - count of unique columns (not stored)
  `nullsDistinct` - are nulls distinct
Returns:
  the index type

#### createNonUnique

    public static IndexType createNonUnique(boolean persistent)

Create a non-unique index.

Parameters:
  `persistent` - if the index is persistent
Returns:
  the index type

#### createNonUnique

    public static IndexType createNonUnique(boolean persistent,
                                            boolean hash,
                                            boolean spatial)

Create a non-unique index.

Parameters:
  `persistent` - if the index is persistent
  `hash` - if a hash index should be used
  `spatial` - if a spatial index should be used
Returns:
  the index type

#### createScan

    public static IndexType createScan(boolean persistent)

Create a scan pseudo-index.

Parameters:
  `persistent` - if the index is persistent
Returns:
  the index type

#### setBelongsToConstraint

    public void setBelongsToConstraint(boolean belongsToConstraint)

Sets if this index belongs to a constraint.

Parameters:
  `belongsToConstraint` - if the index belongs to a constraint

#### getBelongsToConstraint

    public boolean getBelongsToConstraint()

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

Returns:
  if the index belongs to a constraint

#### isHash

    public boolean isHash()

Is this a hash index?

Returns:
  true if it is a hash index

#### isSpatial

    public boolean isSpatial()

Is this a spatial index?

Returns:
  true if it is a spatial index

#### isPersistent

    public boolean isPersistent()

Is this index persistent?

Returns:
  true if it is persistent

#### isPrimaryKey

    public boolean isPrimaryKey()

Does this index belong to a primary key constraint?

Returns:
  true if it references a primary key constraint

#### isUnique

    public boolean isUnique()

Is this a unique index?

Returns:
  true if it is

#### getSQL

    public java.lang.String getSQL(boolean addNullsDistinct)

Get the SQL snippet to create such an index.

Parameters:
  `addNullsDistinct` - `true` to add nulls distinct clause
Returns:
  the SQL snippet

#### isScan

    public boolean isScan()

Is this a table scan pseudo-index?

Returns:
  true if it is

#### getNullsDistinct

    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:
  are nulls distinct, or `null` for non-unique and primary key indexes

#### getEffectiveNullsDistinct

    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:
  are nulls distinct, or `null` for non-unique indexes