Marks records for deletion.

NoteNote

Records marked for deletion are not physically removed from the table until the PACK command is issued. You can recall (unmark) records for deletion by using the RECALL command. For more information, see PACK Command and RECALL Command.

DELETE [Target] FROM [FORCE] Table_List [[, Table_List ...] | [JOIN [ Table_List]]]
   [WHERE FilterCondition1 [AND | OR FilterCondition2 ...]]

Parameters

DELETE [Target]

Specifies a target table, cursor, table or cursor alias, or file for the delete operation. If the FROM specifies more than one table, you must include the Target parameter. Target can have the following syntaxes:

  • [DatabaseName!]TableName

    DatabaseName! specifies the name of a database containing the table if the table is in a noncurrent database. If the table is in a noncurrent database, you must include the name of the database. Use an exclamation point (!) as a delimiter immediately following the database name and preceding the table name.

    TableName specifies the name of a table for the delete operation.

  • Alias

    Alias specifies an alias that matches a table in the FROM clause or a cursor in the current data session for the delete operation.

  • FileName

    FileName specifies the name of a file for the delete operation.

FROM [FORCE] Table_List[[, Table_List...] | [JOIN [Table_List]]]

Specifies one or more tables containing the data for the delete operation.

The FROM clause has the same syntax as in the SQL SELECT command except for the following restrictions:

  • The target table or cursor cannot be included in an OUTER join as a secondary table or cursor.

  • It should be possible to evaluate all other JOIN operations before performing a JOIN operation on the target table.

  • The target cursor cannot be the result from a subquery.

For more information, see SELECT - SQL Command.

FORCE specifies that the tables in Table_List are joined in the order they appear in the FROM clause.

NoteNote

If FORCE is omitted, Visual FoxPro attempts to optimize the delete operation. However, the delete operation might be executed faster by including the FORCE keyword to disable Visual FoxPro delete optimization.

Table_List can have the following syntaxes:

  • [DatabaseName!]Table [[AS] Local_Alias]

    DatabaseName! specifies the name of a database containing the table if the table is in a noncurrent database. If the table is in a noncurrent database, you must include the name of database. Use an exclamation point (!) as a delimiter immediately following the database name and preceding the table name.

    Table specifies the name of the table or cursor you want to retrieve data from. If no table is open, Visual FoxPro displays the Open dialog box so you can specify the file location. After the table opens, it remains open when the query is complete.

    Local_Alias specifies a temporary name for the table specified in Table. If you specify a local alias, you must use the local alias instead of the table name throughout the DELETE statement. The alias can represent a table or a cursor.

    JOIN provides the capability for specifying one or more secondary tables. There is no hard-coded limit on the number of tables, aliases, or JOIN clauses per DELETE statement.

  • (Subquery) AS Subquery_Alias

    Subquery specifies a SELECT statement within another SELECT statement. For more information about subqueries in SELECT statements, see SELECT - SQL Command - FROM Clause.

WHERE FilterCondition1 [AND | OR FilterCondition2...]

Specifies one or more filter conditions that records must meet to be deleted. There is no limit to the number of filter conditions in the WHERE clause.

To reverse the value of a logical expression, use the NOT operator. To check for an empty field, use the EMPTY( ) function. For more information, see EMPTY( ) Function.

Expand imageRemarks

Expand imageExample 1

Expand imageExample 2

Expand imageSee Also