Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In the Answer to somebody else's question it was stated that the Make Query Table tool could be used to re-order fields in tables and feature classes permanently.

However, when I open the dialog for that tool I cannot see anywhere that enables re-ordering of fields. All I can see is that fields can be carried through or dropped using checkboxes but in the same order.

Assuming that it is possible can someone describe the steps in more detail, please?

Make Query Table tool dialog

share|improve this question

2 Answers 2

up vote 7 down vote accepted

I figured out how to do this by using the Make Query Table tool, Copy As Python Snippet, the Python window and the Copy Features tool.

After running the Make Query Table tool to pull through just the fields I wanted to appear in the output I was able to Copy As Python Snippet this code from the Geoprocessing | Results window into the Python window of ArcMap.

arcpy.MakeQueryTable_management("'C:/avhome/data/WAregional/wa regional.mdb/schools'","QueryTable","USE_KEY_FIELDS","#","schools.OBJECTID #;schools.Shape #;schools.CODE #;schools.NAME #;schools.TYPE #;schools.Y11STUDENT #;schools.Y12STUDENT #;schools.COORDGEOCO #;schools.ID #","#")

and edit it to become:

arcpy.MakeQueryTable_management("'C:/avhome/data/WAregional/wa regional.mdb/schools'","QueryTable2","USE_KEY_FIELDS","#","schools.OBJECTID #;schools.Shape #;schools.Y12STUDENT #;schools.Y11STUDENT #;schools.NAME #","#")

Note that the new QueryTable2 retains the Shape field (so I can CopyFeatures it) and I have reordered the NAME,YR11STUDENT & YR12STUDENT fields. I also used the opportunity to drop out a few more fields.

The last step is to use the Copy Features tool on QueryTable2 which I did via its tool dialog to create a new feature class with the fields re-ordered permanently.

share|improve this answer
2  
Note: you can also use MakeQueryTable to change the names of your fields by inputting a list of lists of field names and aliases ([[fieldname1,alias1],[fieldname2,alias2]...]) –  gotanuki Dec 25 '12 at 18:02
    
The same functionality is exposed when you run Feature class to Feature class and then Copy As Python Snippet. –  Alex Tereshenkov Apr 5 at 8:28

Having read this Altering the order of attributes in a table and trying to rearrange the order of fields, I found this simple solution in ArcMap 10,1...

  1. Right-click on feature you want to alter in table of contents
  2. click Properties
  3. click Fields tab
  4. click on a field
  5. click the "move up" or "move down" arrow
  6. Apply, OK

enter image description here

share|improve this answer
1  
Good try. But unfortunately this applies only to the layer you've added into the map document. The feature class will still have the fields in the order defined. Technically speaking, there is no "order" of fields in databases, but as an end user you might want to be able when adding a feature class into a map document and opening an attribute table see the fields in the relevant for you order. –  Alex Tereshenkov Apr 24 at 14:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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