Deletes all or the selected subset of rows from the input.
The deletion of all rows or a subset of rows depends on the following:
If the input is a feature class or table, all rows will be deleted.
If the input is a layer or table view with no selection, all rows will be deleted.
If the input is a layer or table view with a selection, only the selected rows will be deleted.
Usage
The Input Rows parameter value can be a dBASE table, an enterprise or file geodatabase table or feature class, shapefile, layer, or table view.
If this tool is used on feature data, the entire row, including the geometry, will be deleted.
Note:
Deleting all rows from a table with a large number of rows can take time. If the intent is to delete all the rows, consider using the Truncate Table tool instead. See the Truncate Table documentation for important cautionary statements on its use.
The following stand-alone script demonstrates how to use the DeleteRows function to delete rows based on an expression.
# Description: Delete rows from a table based on an expression
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:/data"
# Set local variables
inTable = "accident.dbf"
outTable = "C:/output/new_accident.dbf"
tempTableView = "accidentTableView"
expression = arcpy.AddFieldDelimiters(tempTableView, "Measure") + " = 0"
# Run CopyRows to make a new copy of the table
arcpy.management.CopyRows(inTable, outTable)
# Run MakeTableView
arcpy.management.MakeTableView(outTable, tempTableView)
# Run SelectLayerByAttribute to determine which rows to delete
arcpy.management.SelectLayerByAttribute(tempTableView, "NEW_SELECTION",
expression)
# Run GetCount and if some features have been selected, run
# DeleteRows to remove the selected rows.
if int(arcpy.management.GetCount(tempTableView)[0]) > 0:
arcpy.management.DeleteRows(tempTableView)