ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for 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
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Alter Field

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

Summary

Rename fields and field aliases, or alter field properties.

Usage

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

  • For empty geodatabase tables or feature classes, you can change field properties such as the field type, length, or nullability.

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

Syntax

AlterField_management (in_table, field, {new_field_name}, {new_field_alias}, {field_type}, {field_length}, {field_is_nullable}, {clear_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. If the field is a required field (isRequired=true), only the field alias may 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)

The new field type for the field. 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 on fields of type TEXT or BLOB. Only applicable if table is empty.

Long
field_is_nullable
(Optional)

Determines if the field can contain null values. Null values are only supported for fields in a geodatabase. 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)

Specify whether to clear the alias for the input field. 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

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 geoprocessing
import arcpy

#Set local variables
fc = "C:/Data/Garbo.gdb/trails" #Note:empty feature class
field = "condition_rating" #short int, non nullable field
new_name = "notes"
new_alias = "Comments on Trail Condition"
new_type = "TEXT"
new_length = "60"
new_is_nullable = "NULLABLE"
clear_alias = "FALSE"

#Alter the properties of a non nullable, short data type field to become a text field
arcpy.AlterField_management(fc, field, new_name, new_alias, new_type, new_length, new_is_nullable, clear_alias)

Environments

  • Current Workspace

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Fields toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal