Does this sound familiar?
You are in ArcGIS Pro, and you have just used Select by Attributes to select hundreds, or even thousands, of records from a feature layer or hosted feature service because you need to delete them. You click on that easily accessible red “X” from the edit tab or in the attribute table to delete the records and… ArcGIS Pro crashes. Or, after waiting for ages you receive an error message saying command could not be completed. Either way, you are not alone in this frustrating occurrence, but there are easy ways that you can avoid it.
In this short tutorial, I will focus on how you can delete all records, or a subset of records, from your feature layer or hosted feature service.
Delete Records in a Feature Layer
Delete Rows Geoprocessing Tool
Using the Delete Rows geoprocessing tool in ArcGIS Pro, you can navigate to your feature layer and then click “Run”. If you have selected a subset of records in your feature layer, then only that subset will be deleted. If you have not selected a subset of records, then this will delete all the current records from your feature layer, leaving you with a blank feature layer that is ready for you to append all of the new features and data to. If needed, you can enable Undo, but this type of process is typically done with a lot of intention and foresight.
Keep in mind that this modifies the input feature layer and does not create a new feature layer.
Delete Records in a Hosted Feature Service
If your hosted feature service is added to your ArcGIS Pro project, then you can use the above-mentioned Delete Rows tool. There is also a tool that you can use directly from ArcGIS Online, which is the deleteFeatures operation from the ArcGIS REST Service Directory.
Delete Records using ArcGIS REST Service Directory
You want to keep in mind while using the deleteFeatures operation in ArcGIS Online that there is no option to undo your actions. You can either type in specific ObjectID’s, separated by a comma in the “ObjectID” field or you can use the “Where” field and type in an expression such as, “ObjectID<100000”. This expression would result in the very fast deletion of all ObjectID’s that are smaller than 100,000.
To get to this location in the ArcGIS REST Services Directory, follow the below instructions.
1- From your hosted feature service overview page, click on the layer you want to delete records from.
2- From your layer’s details page, click on the URL option in the lower-right corner that says, “View”.
3- At the services directory page, scroll to the very bottom and click the deleteFeatures link. Your hosted feature service must have editing enabled before you will see the deleteFeatures option appear at the bottom of the page.
Clicking this link will take you to the Delete Features operation where you can enter the object ID’s or expression for the features you would like to delete.
Both of these methods work quickly and accurately. We recommend you carefully approach either method because the accidental loss of features and associated data is a time-consuming action to recover from. To summarize, proceed with caution!