I have a FGDB that I am using to test in Arc Online. In doing so I am performing database updates such as assigning domains, deleting fields, and reordering. I have searched everywhere and not found one good answer that EXPLAINS the process of permanently reordering the feature class attributes. I dont mind a python response as long as it is clear the thinking/process in performing the necessary steps. For instance I need to make the field listed last (all the way to the right) as third (further left). I should mention that eventually i will need to do the same to my production .SDE so the more scripting involved the better for duplication later on.
Solved! Go to Solution.
I encounter this frequently. Export the FGDB to an XML workspace document, then use notepad ++ with the XML plugin to re-arrange the XML element that correspond to "attributes". You're not going to "screw up your database" because with XML, if you get anything wrong, the re-import of the XML into a new empty FGDB will fail.
As for SDE, if this is a MS SQL DB, you can use SQL to edit the table definition XML, as well as do a drop and create on the table itself, with the create ordering the columns as you wish. You'll have to dump your data into another table then re-import it.
Did you see this discussion Is there an easy way to re-order fields in a shapefile's dbf?
I encounter this frequently. Export the FGDB to an XML workspace document, then use notepad ++ with the XML plugin to re-arrange the XML element that correspond to "attributes". You're not going to "screw up your database" because with XML, if you get anything wrong, the re-import of the XML into a new empty FGDB will fail.
As for SDE, if this is a MS SQL DB, you can use SQL to edit the table definition XML, as well as do a drop and create on the table itself, with the create ordering the columns as you wish. You'll have to dump your data into another table then re-import it.
I tried using x-ray in arccatalog but for whatever reason it was not working. I ended up quickly exporting the feature class to a personal geodatabase and using Access i know this isn't best practice but for now it worked. In the future XML sounds like a much more reliable approach.
The SDE is SQL and I will approach later as it is much easier
Try using X-Ray for ArcCatalog to re-arrange, add or remove fields, create domains, etc.. I find it indispensable.
http://www.arcgis.com/home/item.html?id=e1e911d7d7374285b1ef03d06b3ee642
For re-arranging fields, the arcpy.fieldmappings technique works well. The following link nicely demonstrates a Pythonic way to do Field Mappings: