Rearrange Atrribute Fields

3723
5
Jump to solution
10-07-2015 12:32 PM
KevinDunkin1
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
ThomasColson
MVP Frequent Contributor

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.

View solution in original post

5 Replies
WesMiller
Regular Contributor III
0 Kudos
ThomasColson
MVP Frequent Contributor

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.

KevinDunkin1
New Contributor III

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

0 Kudos
ChrisRumig
New Contributor III

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

WillRugg
New Contributor

For re-arranging fields, the arcpy.fieldmappings technique works well. The following link nicely demonstrates a Pythonic way to do Field Mappings:

http://joshwerts.com/blog/2014/04/17/arcpy-reorder-fields/