Partager via


How to: Delete Records in Tables

You can delete records by marking them for deletion, then removing the deleted records. Otherwise, records marked for deletion remain on disk until you remove them. You can also delete and remove all records from a table.

Tip

When viewing records in a browse window, records marked for deletion still appear if the SET DELETED command is set to OFF. To hide records marked for deletion, set the SET DELETED command to ON. SET DELETED also determines whether commands that operate on records can access records marked for deletion. You might also create an index tag using the DELETED( ) function. For more information, see Indexes Based on Deleted Records.

You can restore records marked for deletion before you remove them. For more information, see How to: Restore Deleted Records.

To mark a record for deletion

  1. Open the table in a browse window.

  2. In the browse window, insert the cursor in a field for the record you want to delete.

  3. On the Table menu, click Toggle Deletion Mark.

    The deletion mark appears in the column to the left of the first field in the record.

    Tip

    You can also double-click the column to mark the record for deletion.

For more information, see How to: View Records in Tables.

To mark multiple records for deletion

  1. Open the table in a browse window.

  2. On the Table menu, click Delete Records.

    The Delete dialog box opens.

  3. In the Scope box of the Delete dialog box, select the range of records you want to delete.

  4. In the For box, type an expression that records must meet to include for deletion. To build an expression, click the ellipsis (...) button.

  5. In the While box, type an expression that evaluates to true in order to continue evaluating records to include for deletion.

  6. When you are finished, click Delete.

For more information, see How to: View Records in Tables and Delete (Records) Dialog Box.

To mark records for deletion programmatically

  • Use the SQL DELETE command.

For more information, see DELETE - SQL Command.

To delete and remove all records from a table

  • Use the ZAP command.

For more information, see ZAP Command.

Note

Before you use the ZAP command, make sure the table has been opened exclusively.

Warning

Records deleted and removed with ZAP cannot be restored.

See Also

Tasks

How to: Remove Deleted Records

Other Resources

Working with Records

Working with Tables (Visual FoxPro)