Select to view content in your preferred language

Tool to Delete Geodatabase content (feature classes, tables, etc)?

2774
1
Jump to solution
08-28-2015 07:42 AM
EduardoAbreu-Freire
Regular Contributor

Situation:

Need to add a Tool to my ModelBuider to Delete only the content from an Enterprise (SDE) Geodatabase (containing features classes, tables, relationship classes).

Tool "Delete" (from Toolbox "Data Management") deletes the Geodatabase and only want to delete its content.

Any help?

0 Kudos
1 Solution

Accepted Solutions
FreddieGibson
Honored Contributor

The easiest option would be to build a script tool to use the arcpy.da.walk method to walk through your geodatabase and delete each item found.

arcpy.da.walk

http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/walk.htm

If you wanted to accomplish this in ModelBuilder you could build a series of submodels with the different iterators that could delete different types of data.

A quick tour of using iterators

http://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/a-quick-tour-of-using-iterators-for...

The catch with using the iterators within ModelBuilder with be that 1) not all types are available within the given set of iterators and 2) without using a script tool for the deletion logic it'd be hard to catch errors that would stop the model (i.e. deleting features that you don't have permissions to, items that can't be deleted because they participate in a relationship, etc.)

View solution in original post

1 Reply
FreddieGibson
Honored Contributor

The easiest option would be to build a script tool to use the arcpy.da.walk method to walk through your geodatabase and delete each item found.

arcpy.da.walk

http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/walk.htm

If you wanted to accomplish this in ModelBuilder you could build a series of submodels with the different iterators that could delete different types of data.

A quick tour of using iterators

http://desktop.arcgis.com/en/desktop/latest/analyze/modelbuilder/a-quick-tour-of-using-iterators-for...

The catch with using the iterators within ModelBuilder with be that 1) not all types are available within the given set of iterators and 2) without using a script tool for the deletion logic it'd be hard to catch errors that would stop the model (i.e. deleting features that you don't have permissions to, items that can't be deleted because they participate in a relationship, etc.)