Delete all Features and Tables within a FGDB?

252
2
Jump to solution
03-07-2019 10:37 AM
by Anonymous User
Not applicable

What's the simplest way to delete all of the contents in a FGDB using arcpy?

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

I was able to get the following code to work.

import arcpy  
arcpy.env.workspace = r"XXXXXXXXXXXXXXXXXXX"  
for objFeatureClass in arcpy.ListFeatureClasses():  
    arcpy.Delete_management(objFeatureClass)
for objTables in arcpy.ListTables():  
    arcpy.Delete_management(objTables)
print "Process Complete"

View solution in original post

2 Replies
DanPatterson_Retired
MVP Emeritus

If there will be nothing left, just delete the gdb. then recreate it with the same name.

Or is there something else that needs to be maintained? 

by Anonymous User
Not applicable

I was able to get the following code to work.

import arcpy  
arcpy.env.workspace = r"XXXXXXXXXXXXXXXXXXX"  
for objFeatureClass in arcpy.ListFeatureClasses():  
    arcpy.Delete_management(objFeatureClass)
for objTables in arcpy.ListTables():  
    arcpy.Delete_management(objTables)
print "Process Complete"