Condividi tramite


Permitting Duplicate Values

In Visual FoxPro, a unique index does not prevent duplicate values from being created; rather, a unique index stores only the first occurrence of the value in the index file. In this sense, the word "unique" refers to the entries in the index file, which contains only unique values, because it doesn't store a particular key more than once, and ignores the second or later occurrence of a non-unique value. The table indexed by a unique index could contain duplicate values. Unique index types are provided primarily for backward compatibility.

A regular index is simply an index that is not unique, primary, or candidate. You use a regular index for ordering and seeking records, but not to enforce the uniqueness of the data in those records. You also use a regular index as the many side of a one-to-many persistent relationship.

To create a regular index

  • In the Table Designer, select the Index tab and create an index, by selecting Regular as the index type.

    -or-

  • Use the INDEX command.

For example, the following commands make city a regular key for the customer table:

USE customer 
INDEX ON city TAG city

See Also

Setting a Primary or Candidate Index | Creating Multiple Indexes | Working with Records | Setting Record Order at Run Time | Creating One Index | Ordering by Multiple Fields | Index Creation for Tables