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?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Dec 5, 2013 at 0:56
2
  • 3
    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. Commented Dec 5, 2013 at 1:06
  • Thanks a lot. This solved the problem! How can I mark your answer correct? Commented Dec 5, 2013 at 2:07

2 Answers 2

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.

answered Dec 5, 2013 at 2:13
-2

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)
Andre Silva
10.5k12 gold badges57 silver badges109 bronze badges
answered Apr 4, 2016 at 11:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.