ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Delete Rows

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Deletes all or the selected subset of rows from the input.

If the input rows are from a feature class or table, all rows will be deleted. If the input rows are from a layer or table view with no selection, all rows will be deleted.

Usage

  • The Input Rows parameter can be an INFO or dBASE table, ArcSDE, file, or personal 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.

  • If a layer or table view is input, and the layer or table view does not have a selection, all rows will be deleted. If a table is input, all rows will be deleted.

    Note:

    Deleting all rows from a table with a large number of rows can be slow. If your intent is to delete all the rows in the table you should consider using the Truncate Table tool instead. Please see the Truncate Table documentation for important cautionary statements on its use.

  • When working in ArcMap and using a layer or table view with a selection as input, using this tool in an edit session will allow for the Delete Rows operation to be undone using undo/redo.

Syntax

DeleteRows_management (in_rows)
ParameterExplanationData Type
in_rows

The feature class, layer, table, or table view whose rows will be deleted.

Table View

Code sample

DeleteRows example 1 (Python window)

The following Python window script demonstrates how to use the DeleteRows function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.CopyRows_management("accident.dbf", "C:/output/accident2.dbf")
arcpy.DeleteRows_management("C:/output/accident2.dbf")
DeleteRows example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the DeleteRows function to delete rows based on an expression.

# Name: DeleteRows_Example2.py
# Description: Delete rows from a table based on an expression
 
# Import system modules
import arcpy

try: 
    # 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"
 
    # Execute CopyRows to make a new copy of the table
    arcpy.CopyRows_management(inTable, outTable)
 
    # Execute MakeTableView
    arcpy.MakeTableView_management(outTable, tempTableView)
 
    # Execute SelectLayerByAttribute to determine which rows to delete
    arcpy.SelectLayerByAttribute_management(tempTableView, "NEW_SELECTION", expression)
 
    # Execute GetCount and if some features have been selected, then execute
    #  DeleteRows to remove the selected rows.
    if int(arcpy.GetCount_management(tempTableView).getOutput(0)) > 0:
        arcpy.DeleteRows_management(tempTableView)
         
except Exception as err:
    print(err.args[0])

Environments

  • Current Workspace

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Table toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal