1

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?

  • 2
    Is 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 Dec 5 '13 at 1:06
  • Thanks a lot. This solved the problem! How can I mark your answer correct? – alextc Dec 5 '13 at 2:07
3

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.

-1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.