Skip To Content

Add a unique constraint to a field

You can apply a unique constraint to individual fields in sublayers in a hosted feature layer. When you apply a unique constraint, the relational data store ensures that there are no duplicate values stored in the field. You might do this for fields you intend to use to uniquely identify features in the layer. When editors update attributes or add features to a layer, the unique constraint ensures the editor does not add duplicate values. When you append or update data in the feature layer, if the file you use to append or update fields contains a value that violates the unique constraint, the append or update operation will fail.

In most cases, unique constraints are applied to numeric fields, but you can set a unique constraint on any field type except system fields such as ObjectID, GlobalID, and FID.

The layer owner and the organization administrator can set unique constraints on fields in hosted feature layers.

Follow these steps to add a unique constraint to a field in a sublayer of a hosted feature layer:

  1. Open the item page for the hosted feature layer.
  2. Click the Data tab.
  3. If the hosted feature layer contains more than one sublayer, use the Layer drop-down menu to choose the sublayer to configure.
  4. Click the display name of the field to which you will add a unique constraint.

    Details for the field appear.

  5. Under Settings, click Edit in the Unique field.
  6. Check the Field contains unique values check box and click Save.

    ArcGIS Enterprise confirms that existing values in the field are unique. If they are, the unique constraint is added, and the Unique value is updated to indicate that the field has a unique constraint applied to it. If values are not unique, you cannot set a unique constraint on this field until you edit the field so it contains only unique values.

If you later decide to remove the unique constraint, edit the Unique field again, uncheck Field contains unique values, and click Save.