I am trying to automate the rebuild of file geodatabase indexes using ArcPy v10.6, but I encounter an ERROR 000837 The workspace is not the correct workspace type.
Question: If arcpy.RebuildIndexes_management() works only with Enterprise geodatabases, then how to rebuild indexes in file geodatabases?
import arcpy, os
workspace = "C:/tmp/myDatabase.gdb"
fc = "MyFeatureClass"
arcpy.Exists(workspace)
>>>True
arcpy.Exists(os.path.join(workspace, fc))
>>>True
arcpy.RebuildIndexes_management(workspace, "NO_SYSTEM", [fc], "ALL")
>>>ERROR 000837 The workspace is not the correct workspace type
.
1 Answer 1
That method cannot be used on a file geodatabase, from the tool help document, see usage statement below:
Data must be from a database or an enterprise, workgroup, or desktop geodatabase. This tool does not work with file or personal geodatabases.
To add an index to an existing feature class within a geodatabase you may use the Add Attribute Index or Add Spatial Index method:
-
I can't accept your post, because it does not really answer my questionBelow the Radar– Below the Radar2019年12月04日 20:00:50 +00:00Commented Dec 4, 2019 at 20:00
-
2@BelowtheRadar how does this not answer your question? They explain why that tool does not work ( something easily solved if the help file had been researched) and they provide a solution, the add attribute tool. Suggest you explore the section of the help file about the index tools?Hornbydd– Hornbydd2019年12月04日 21:30:06 +00:00Commented Dec 4, 2019 at 21:30
-
@Hornbydd because I am asking what is the proper way to rebuild indexes with arcpy inside file geodatabase, not why it's not working with arcpy.RebuildIndexes_management()Below the Radar– Below the Radar2019年12月04日 21:33:14 +00:00Commented Dec 4, 2019 at 21:33
-
2The answer above is the only way to build an attribute index for a file geodatabase.Hornbydd– Hornbydd2019年12月04日 21:36:55 +00:00Commented Dec 4, 2019 at 21:36
-
I want to rebuild existing indexes, so the answer should be something like, get the indexes infos from the featureClass, drop those indexes and create the indexes againBelow the Radar– Below the Radar2019年12月04日 21:39:47 +00:00Commented Dec 4, 2019 at 21:39