ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Alter Field

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Renames fields and field aliases, or alters field properties.

Usage

  • This tool provides the ability to rename fields or field aliases for any geodatabase table or feature class.

  • When using in memory feature classes or tables, renaming the ObjectID, Shape, or other required fields such as those found in network analysis layers can result in corrupted data or unexpected behavior.

Syntax

arcpy.management.AlterField(in_table, field, {new_field_name}, {new_field_alias}, {field_type}, {field_length}, {field_is_nullable}, {clear_field_alias})
ParameterExplanationData Type
in_table

The input table or feature class that contains the field to alter.

Table View; Raster Layer; Raster Catalog Layer; Mosaic Layer
field

The name of the field to alter. If the field is a required field (isRequired=true), only the field alias can be altered.

Field
new_field_name
(Optional)

The new name for the field.

String
new_field_alias
(Optional)

The new field alias for the field.

String
field_type
(Optional)

Specifies the new field type for the field. This property is only applicable if the input table is empty (does not contain records).

  • TEXT —Any string of characters.
  • FLOAT — Fractional numbers between -3.4E38 and 1.2E38.
  • DOUBLE — Fractional numbers between -2.2E308 and 1.8E308.
  • SHORT — Whole numbers between -32,768 and 32,767.
  • LONG — Whole numbers between -2,147,483,648 and 2,147,483,647.
  • DATE —Date and/or time.
  • BLOB —Long sequence of binary numbers. You need a custom loader or viewer or a third-party application to load items into a BLOB field or view the contents of a BLOB field.
  • RASTER —Raster images. All ArcGIS software-supported raster dataset formats can be stored, but it is highly recommended that only small images be used.
  • GUID —Globally unique identifier.
String
field_length
(Optional)

The new length of the field. This sets the maximum number of allowable characters for each record of the field. This option is only applicable to fields of type TEXT or BLOB. It is also only applicable if the table is empty.

Long
field_is_nullable
(Optional)

Specifies whether the field can contain null values. Null values are only supported for fields in a geodatabase. This option is only applicable if the input table is empty (does not contain records).

  • NON_NULLABLE —The field will not allow null values.
  • NULLABLE —The field will allow null values. This is the default.
Boolean
clear_field_alias
(Optional)

Specifies whether the alias for the input field will be cleared. The field alias parameter must be empty to clear the alias of the field.

  • TRUE —The field alias will be cleared (set to null).
  • FALSE —The field alias will not be cleared. This is the default.
Boolean

Derived Output

NameExplanationData Type
out_table

The updated input table.

Table View; Raster Layer; Mosaic Layer

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.name, 'ELEVATION', 'Elevation in Metres')
AlterField example 3 (stand-alone script)

The following Python window script demonstrates how to use the AlterField tool on an empty feature class in a stand-alone script.

#Import arcpy module
import arcpy

#Set local variables
in_table = "C:/Data/Garbo.gdb/trails" #Note: empty feature class
field = "condition_rating" #short int, non nullable field
new_field_name = "notes"
new_field_alias = "Comments on Trail Condition"
field_type = "TEXT"
field_length = "60"
field_is_nullable = "NULLABLE"
clear_field_alias = "FALSE"

#Alter the properties of a non nullable, short data type field to become a text field
arcpy.management.AlterField(in_table,
                            field,
                            new_field_name,
                            new_field_alias,
                            field_type,
                            field_length,
                            field_is_nullable,
                            clear_field_alias)

Environments

  • Current Workspace

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics

  • An overview of the Fields toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2022 Esri. | Privacy | Legal