Add Fields (multiple) (Data Management)

Summary

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

Usage

  • 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.

  • The Add Fields tool has the following default field properties:

    • Added fields Allow NULL property will be true.
    • Added fields Editable property will be true.
    • Added fields Required property will be false.
    • Precision and scale are set by the field type and data source defaults.

  • The field length 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

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 given to the field name. This is used to give more descriptive names to cryptic field names. The Field Alias parameter 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:

  • 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 recommended that you use small images only.
  • GUID—Globally unique identifier.
Value Table

Derived Output

LabelExplanationData Type
Updated Input Table

The updated input tables.

Table View; Raster Layer; Mosaic Layer

arcpy.management.AddFields(in_table, field_description)
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}],...]

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 given to the field name. This is used to give more descriptive names to cryptic field names. The Field Alias parameter 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:

  • 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 recommended that you use small images only.
  • GUID—Globally unique identifier.

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

Value Table

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 tool 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

Licensing information

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

Related topics