I have a python script that deletes all features on an ArcSDE feature table and then inserts new features to it.
I noted that the ObjectID keeps incrementing from where the last feature was with before deleted.
Just wondering if there is any reset function or tool to make ObjectID start with 1 every time the script runs?
-
3Is your ArcSDE versioned? If so, I suspect your deletions are still being kept track of so the ObjectID would remain required. If not versioned, or if versioning can be removed as part of your script, then perhaps consider using Truncate Table to get a performance gain on your deletions. I suspect that this would reset your ObjectID counter.PolyGeo– PolyGeo ♦2013年12月05日 01:06:27 +00:00Commented Dec 5, 2013 at 1:06
-
Thanks a lot. This solved the problem! How can I mark your answer correct?alextc– alextc2013年12月05日 02:07:57 +00:00Commented Dec 5, 2013 at 2:07
2 Answers 2
If your ArcSDE is versioned, then I suspect your deletions are still being kept track of so the ObjectID would remain required.
If not versioned, or if versioning can be removed as part of your script, then perhaps consider using Truncate Table to get a performance gain on your deletions.
I suspect that this would reset your ObjectID counter.
this works great also without resetting your objID!
OBJ = arcpy.Describe(<layer>).OIDFieldName
with arcpy.da.SearchCursor(<layer>, OBJ) as Scursor:
for row in Scursor:
b = '''"{}"'''.format(OBJ) + " = {}".format(row[0])
arcpy.SelectLayerByAttribute_management(<layer>, "NEW_SELECTION", b)
Explore related questions
See similar questions with these tags.