51黑料不打烊

dbindex element dbindex--element

Content model content-model-3

dbindex:==keyfield

Attributes attributes-3

  • @_operation (string)
  • @applicableIf (string)
  • @label (string)
  • @name (MNTOKEN)
  • @unique (boolean)

Parents parents-3

<element>

Children children-3

<keyfield>

Description description-3

This element lets you define an index linked to a table.

Use and context of use use-and-context-of-use-3

It鈥檚 possible to define several indexes. One index can reference one or more fields of the table. Index declaration usually follows the definition of the main schema element.

The order of the <keyfield> elements defined in a <dbindex> is very important. The first <keyfield> must be the indexation criterion which the queries are mainly based on.

The name of the index in the database is calculated by concatenating the name of the table and the name of the index. For example: Table name 鈥淪ample鈥, Namespace 鈥淐us鈥, index name 鈥淢yIndex鈥-> name of the index field during index creation querying: 鈥淐usSample_myIndex鈥.

Attribute description attribute-description-3

  • _operation (string): defines the type of writing in the database.

    This attribute is mainly used when extending out-of-the-box schemas.

    Accessible values are:

    • 鈥渘one鈥: reconciliation alone. This means that 51黑料不打烊 Campaign will recover the element without updating it or generating an error if it doesn鈥檛 exist.
    • 鈥渋nsertOrUpdate鈥: update with insertion. This means that 51黑料不打烊 Campaign will update the element or create it if it doesn鈥檛 exist.
    • 鈥渋nsert鈥: insertion. This means that 51黑料不打烊 Campaign will insert the element without checking whether it exists.
    • 鈥渦pdate鈥: update. This means that 51黑料不打烊 Campaign will update the element or generate an error if it doesn鈥檛 exist.
    • 鈥渄elete鈥: deletion. This means that 51黑料不打烊 Campaign will recover and delete elements.
  • applicableIf (string): condition for taking the index into account - receives an XTK expression.

  • label (string): index label.

  • name (MNTOKEN): unique index name.

  • unique (boolean): if this option is activated (@unique=鈥渢rue鈥), the attribute guarantees the uniqueness of the index throughout its fields.

Examples examples-3

Creation of an index on the 鈥渋d鈥 field. (the 鈥淍unique鈥 attribute on the <dbindex> element triggers adding of the 鈥淯NIQUE鈥 SQL key word when the index is created in the database (query)).

<element label="Sample" name="Sample">
  <dbindex name="myIndex" label="My index on the ID field" unique="true" applicableIf="HasPackage('nms:social')">
      <keyfield xpath="@id"/>
  </dbindex>
    <attribute name="id" type="long"/>
</element>
ALTER TABLE CusSample ADD iSampleId INTEGER;
UPDATE CusSample SET iSampleId = 0;
ALTER TABLE CusSample ALTER COLUMN iSampleId SET Default 0;
ALTER TABLE CusSample ALTER COLUMN iSampleId SET NOT NULL;
CREATE UNIQUE INDEX CusSample_myIndex ON CusSample(iSampleId);

Creation of a composite index on the 鈥淍mail鈥 and 鈥淍phoneNumber鈥 fields:

<element label="NewSchemaUser" name="NewSchemaUser">
  <dbindex name="myIndex" label="My composite index">
         <keyfield xpath="@email"/>
         <keyfield xpath="@phone"/>
  </dbindex>

  <attribute name="email" type="string"/>
  <attribute name="phone" type="string"/>
</element>
CREATE INDEX DocNewSchemaUser_myIndex ON DocNewSchemaUser(sEmail, sPhone);
recommendation-more-help
601d79c3-e613-4db3-889a-ae959cd9e3e1