DataMgr 2.5 Documentation: Indexes

Indexes

This feature is considered experimental at this stage as it hasn't been well tested yet.

Only valid on data stores that support this feature

You can define indexes in DataMgr or use DataMgr to tell you what indexes exist in your database.

Find Indexes

To get the indexes for a table or tables, simply set the "indexes" argument to true when calling either getXml() or getDatabaseXml(). It will return the index information in the first format below.

Creating Indexes

You can ensure the existence of an index by using loadXml() just as you would ensure the existence of tables and columns. The formats available are flexible.

Option 1:

<tables>
  <table name="dmBasics">
    <field ColumnName="RecordID" CF_DataType="CF_SQL_INTEGER" PrimaryKey="true" Increment="true" />
    <field ColumnName="RecordVal" CF_DataType="CF_SQL_VARCHAR" Length="80" />
    <field ColumnName="RecordDescrip" CF_DataType="CF_SQL_LONGVARCHAR" />
    <index indexname="frank" fields="RecordVal,RecordDescrip" />
  </table>
</tables>

Or with unique option:

<tables>
<table name="dmBasics">
    <field ColumnName="RecordID" CF_DataType="CF_SQL_INTEGER" PrimaryKey="true" Increment="true" />
    <field ColumnName="RecordVal" CF_DataType="CF_SQL_VARCHAR" Length="80" />
    <field ColumnName="RecordDescrip" CF_DataType="CF_SQL_LONGVARCHAR" />
    <index indexname="frank" fields="RecordVal" unique="true" />
  </table>
</tables>

Option 2:

<tables>
  <table name="dmBasics">
    <field ColumnName="RecordID" CF_DataType="CF_SQL_INTEGER" PrimaryKey="true" Increment="true" />
    <field ColumnName="RecordVal" CF_DataType="CF_SQL_VARCHAR" Length="80" />
    <field ColumnName="RecordDescrip" CF_DataType="CF_SQL_LONGVARCHAR" />
  </table>
  <indexes>
    <index table="dmBasics" indexname="frank" fields="RecordVal" />
  </indexes>
</tables>

Option 3:

<tables>
  <table name="dmBasics">
    <field ColumnName="RecordID" CF_DataType="CF_SQL_INTEGER" PrimaryKey="true" Increment="true" />
    <field ColumnName="RecordVal" CF_DataType="CF_SQL_VARCHAR" Length="80" />
    <field ColumnName="RecordDescrip" CF_DataType="CF_SQL_LONGVARCHAR" />
  </table>
  <indexes table="dmBasics">
    <index indexname="frank" fields="RecordVal" />
  </indexes>
</tables>