Freigeben über


Deleting an Index

You can delete indexes you're no longer using by deleting the tag within the .cdx file, or by deleting the .idx file itself for stand-alone indexes. Deleting unused index tags improves performance by removing the need for Visual FoxPro to update unused tags to reflect changes in a table's data.

Deleting a Tag from the Structural .cdx File

You can remove a tag from the structural .cdx file using the Table Designer or the language.

To delete an index tag in the structural .cdx

For example, if your employee table contained a tag called title, you could delete it using the following code:

USE employee
DELETE TAG title

If the tag you wanted to delete was the primary key for the employee table, you could use the ALTER TABLE command:

USE employee
ALTER TABLE DROP PRIMARY KEY

Deleting a Tag from a Non-Structural .cdx File

A non-structural .cdx index and its tags are not visible in the Table Designer. You use the language to delete a tag from a non-structural .cdx file.

To delete an index in a non-structural .cdx file

You use the OF clause with the DELETE TAG command to direct Visual FoxPro to delete a tag from a .cdx other than the structural .cdx file. For example, if you have a non-structural .cdx file named QRTLYRPT.CDX with a tag called title, you could delete the title tag with the following command:

DELETE TAG title OF qtrlyrpt

You delete all the tags in a structural or non-structural .cdx file with the ALL clause of the DELETE TAG command.

Deleting a Stand-Alone .idx Index File

Because a stand-alone index file contains only a single index key expression, you delete the expression by deleting the .idx file from disk.

To delete a stand-alone .idx file

For example, the following code deletes the stand-alone .idx index file Orddate.idx:

DELETE FILE orddate.idx

You could also use a utility, such as Windows Explorer, to delete an unneeded stand-alone .idx file.

See Also

Deleting an Index | Index Creation Based on Expressions | Working with Records | Table Designer | Creating One Index | Creating Multiple Indexes | Ordering by Multiple Fields | Index Creation for Tables