Add Fields (multiple) (Data Management)

Summary

Adds new fields to a table, feature class, or raster.

Usage

    Caution:

    This tool modifies the input data. See Tools that modify or update the input data for more information and strategies to avoid undesired data changes.

  • For shapefiles and dBase tables, if field type defines a character, blanks are inserted for each record. If field type defines a numeric item, zeros are inserted for each record.

  • Fields specified by the Field Properties parameter will have the following default properties:

    • The Allow NULL property will be true.
    • The Editable property will be true.
    • The Required property will be false.
    • The Precision and Scale properties are set by the field type and data source defaults.

  • Fields can be added to the input using either the Field Properties or Template Tables parameter. If values for both parameters are provided, fields will be added from both parameters.

  • The Field Properties parameter's Field Length option is only applicable to fields of type text.

  • A shapefile does not support aliases for fields, so you cannot add a field alias to a shapefile.

  • A field of type raster allows you to include a raster image as an attribute. It is stored in or alongside the geodatabase. This is helpful when an image is the best way to describe a feature. Precision, scale, and length cannot be set for fields of type raster.

Parameters

LabelExplanationData Type
Input Table

The input table where the fields will be added. The fields will be added to the existing input table and will not create a new output table.

Fields can be added to feature classes in geodatabases, shapefiles, coverages, stand-alone tables, raster catalogs, rasters with attribute tables, and layers.

Table View; Raster Layer; Mosaic Layer
Field Properties
(Optional)

The fields and their properties that will be added to the input table.

  • Field Name—The name of the field that will be added to the input table.
  • Field Type—The type of the new field.
  • Field Alias—The alternate name for a field. This is used to describe cryptic field names. This value only applies to geodatabases.
  • Field Length—The length of the field being added. This sets the maximum number of allowable characters for each record of the field. This option is only applicable to fields of type text. The default length is 255.
  • Default Value—The default value of the field.
  • Field Domain—The geodatabase domain that will be assigned to the field.

Available field types are as follows:

  • Short (16-bit integer)—The field type will be short. Short fields support whole numbers between -32,768 and 32,767.
  • Long (32-bit integer)—The field type will be long. Long fields support whole numbers between -2,147,483,648 and 2,147,483,647.
  • Big integer (64-bit integer)—The field type will be big integer. Big integer fields support whole numbers between -(253) and 253.
  • Float (32-bit floating point)—The field type will be float. Float fields support fractional numbers between -3.4E38 and 1.2E38.
  • Double (64-bit floating point)—The field type will be double. Double fields support fractional numbers between -2.2E308 and 1.8E308.
  • Text—The field type will be text. Text fields support a string of characters.
  • Date—The field type will be date. Date fields support date and time values.
  • Date only—The field type will be date only. Date only fields support date values with no time values.
  • Time only—The field type will be time only. Time only fields support time values with no date values.
  • Timestamp offset—The field type will be timestamp offset. Timestamp offset fields support a date, time, and offset from a UTC value.
  • Blob (binary data)—The field type will be BLOB. BLOB fields support data stored as a 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.
  • GUID (globally unique identifier)—The field type will be GUID. GUID fields store registry-style strings consisting of 36 characters enclosed in curly brackets.
  • Raster imagery—The field type will be raster. Raster fields can store raster data in or alongside the geodatabase. All ArcGIS software-supported raster dataset formats can be stored, but it is recommended that only small images be used.
Value Table
Template Tables
(Optional)

The feature classes or tables that will be used as a template to define the attribute fields to add.

Fields from the inputs specified with this parameter will be added to the Input Table value in addition to any fields specified by the Field Properties parameter.

Table View

Derived Output

LabelExplanationData Type
Updated Input Table

The updated input tables.

Table View; Raster Layer; Mosaic Layer

arcpy.management.AddFields(in_table, {field_description}, {template})
NameExplanationData Type
in_table

The input table where the fields will be added. The fields will be added to the existing input table and will not create a new output table.

Fields can be added to feature classes in geodatabases, shapefiles, coverages, stand-alone tables, raster catalogs, rasters with attribute tables, and layers.

Table View; Raster Layer; Mosaic Layer
field_description
[[Field Name, Field Type, {Field Alias}, {Field Length}, {Default Value} {Field Domain}],...]
(Optional)

The fields and their properties that will be added to the input table.

  • Field Name—The name of the field that will be added to the input table.
  • Field Type—The type of the new field.
  • Field Alias—The alternate name for a field. This is used to describe cryptic field names. This value only applies to geodatabases.
  • Field Length—The length of the field being added. This sets the maximum number of allowable characters for each record of the field. This option is only applicable to fields of type text. The default length is 255.
  • Default Value—The default value of the field.
  • Field Domain—The geodatabase domain that will be assigned to the field.

Available field types are as follows:

  • SHORT—The field type will be short. Short fields support whole numbers between -32,768 and 32,767.
  • LONG—The field type will be long. Long fields support whole numbers between -2,147,483,648 and 2,147,483,647.
  • BIGINTEGER—The field type will be big integer. Big integer fields support whole numbers between -(253) and 253.
  • FLOAT—The field type will be float. Float fields support fractional numbers between -3.4E38 and 1.2E38.
  • DOUBLE—The field type will be double. Double fields support fractional numbers between -2.2E308 and 1.8E308.
  • TEXT—The field type will be text. Text fields support a string of characters.
  • DATE—The field type will be date. Date fields support date and time values.
  • DATEONLY—The field type will be date only. Date only fields support date values with no time values.
  • TIMEONLY—The field type will be time only. Time only fields support time values with no date values.
  • TIMESTAMPOFFSET—The field type will be timestamp offset. Timestamp offset fields support a date, time, and offset from a UTC value.
  • BLOB—The field type will be BLOB. BLOB fields support data stored as a 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.
  • GUID—The field type will be GUID. GUID fields store registry-style strings consisting of 36 characters enclosed in curly brackets.
  • RASTER—The field type will be raster. Raster fields can store raster data in or alongside the geodatabase. All ArcGIS software-supported raster dataset formats can be stored, but it is recommended that only small images be used.

In the field_description parameter with optional parameters, use None as an empty place holder.

Value Table
template
[template,...]
(Optional)

The feature classes or tables that will be used as a template to define the attribute fields to add.

Fields from the inputs specified with this parameter will be added to the in_table value in addition to any fields specified by the field_description parameter.

Table View

Derived Output

NameExplanationData Type
out_table

The updated input tables.

Table View; Raster Layer; Mosaic Layer

Code sample

AddFields example (Python window)

The following Python window script demonstrates how to use the AddFields function in immediate mode.


import arcpy
arcpy.env.workspace = "C:/data/district.gdb"
arcpy.management.AddFields(
    'school', 
    [['school_name', 'TEXT', 'Name', 255, 'Hello world', ''], 
     ['street_number', 'LONG', 'Street Number', None, 35, 'StreetNumDomain'],
     ['year_start', 'DATE', 'Year Start', None, '2017-08-09 16:05:07', '']])

Environments