Alter Field (Data Management)

License Level:BasicStandardAdvanced

Summary

Rename fields and field aliases.

Usage

Syntax

AlterField_management (in_table, field, {new_field_name}, {new_field_alias})
ParameterExplanationData Type
in_table

Input table or feature class that contains the field to alter.

Table View
field

The name of the field to alter.

Field
new_field_name
(Optional)

The new name for the field.

String
new_field_alias
(Optional)

The new field alias for the field.

String

Code Sample

AlterField example 1 (Python window)

The following Python window script demonstrates how to use the AlterField tool in immediate mode.

arcpy.AlterField_management(r'C:\Data\Garbo.gdb\Khyber', 'Elev', 'ELEVATION', 'Elevation in Metres')
AlterField example 2 (stand-alone script)

The following Python window script demonstrates how to use the AlterField tool in a stand-alone script.

#Import geoprocessing
import arcpy

#Set workspace
arcpy.env.workspace = r'C:\Data\Garbo.gdb'

#Loop through feature classes looking for a field named 'elev'
fcList = arcpy.ListFeatureClasses() #get a list of feature classes
for fc in fcList:  #loop through feature classes
    fieldList = arcpy.ListFields(fc)  #get a list of fields for each feature class
    for field in fieldList: #loop through each field
        if field.name.lower() == 'elev':  #look for the name elev
            arcpy.AlterField_management(fc, field, 'ELEVATION', 'Elevation in Metres')

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015