Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Data Management toolbox > Fields toolset > Tools

Add Field (Data Management)

Release 9.2
Last modified November 29, 2010
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

Adds a field to the table of a feature class, feature layer and/or raster catalog.

Learn more about how Add Field works


Usage tips

Command line syntax
An overview of the Command Line window
AddField_management <in_table> <field_name> <LONG | TEXT | FLOAT | DOUBLE | SHORT | DATE | BLOB> {field_precision} {field_scale} {field_length} {field_alias} {NULLABLE | NON_NULLABLE} {NON_REQUIRED | REQUIRED} {field_domain}

Parameter Explanation Data Type
<in_table>

The input table to which the specified field will be added. The field will be added to the existing input table and will not create a new output table.

Fields can be added to feature classes of ArcSDE, file or personal geodatabases, coverages, shapefiles, raster catalogs, standalone tables, and/or layers.

Table View | Raster Layer
<field_name>

The name of the field that will be added to the Input Table.

String
<LONG | TEXT | FLOAT | DOUBLE | SHORT | DATE | BLOB>

The field type used in the creation of the new field.

  • TEXT — Names or other textual qualities.
  • FLOAT — Numeric values with fractional values within a specific range.
  • DOUBLE — Numeric values with fractional values within a specific range.
  • SHORT — Numeric values without fractional values within a specific range; coded values.
  • LONG — Numeric values without fractional values within a specific range.
  • DATE — Date and/or Time.
  • BLOB — Images or other multimedia.
  • RASTER — Raster images.

String
{field_precision}

Describes the number of digits that can be stored in the field. All digits are counted no matter what side of the decimal they are on.

If the input table is a personal or file geodatabase the field precision value will be ignored.

Long
{field_scale}

Sets the number of decimal places stored in a field. This parameter is only used in Float and Double data field types.

If the input table is a personal or file geodatabase the field scale value will be ignored.

Long
{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 on fields of type text or blob.

Long
{field_alias}

The alternate name given to the field name. This name is used to give more descriptive names to cryptic field names. The field alias parameter only applies to geodatabases and coverages.

String
{NULLABLE | NON_NULLABLE}

A geographic feature where there is no associated attribute information. These are different from zero or empty fields and are only supported for fields in a geodatabase.

  • NON_NULLABLE — The field will not allow null values.
  • NULLABLE — The field will allow null values. This is the default.

Boolean
{NON_REQUIRED | REQUIRED}

Specifies whether the field being created is a required field for the table; Only supported for fields in a geodatabase.

  • NON_REQUIRED — The field is not a required field. This is the default.
  • REQUIRED — The field is a required field. This means new records must contain a value for the field. Required fields are permanent and can not be deleted.

Boolean
{field_domain}

Used to constrain the values allowed in any particular attribute for a table, feature class, or subtype in a geodatabase. You must specify the name of an existing domain for it to be applied to the field.

String
Data types for geoprocessing tool parameters


Command line example

AddField "C:\test_data\harvestable.shp" year long 9
AddField ("redlands.mdb\streets" ref_ID long 9 # # refcode NULLABLE REQUIRED #)

Scripting syntax
About getting started with writing geoprocessing scripts
AddField_management (in_table, field_name, field_type, field_precision, field_scale, field_length, field_alias, field_is_nullable, field_is_required, field_domain)

Parameter Explanation Data Type
in_table (Required)

The input table to which the specified field will be added. The field will be added to the existing input table and will not create a new output table.

Fields can be added to feature classes of ArcSDE, file or personal geodatabases, coverages, shapefiles, raster catalogs, standalone tables, and/or layers.

Table View | Raster Layer
field_name (Required)

The name of the field that will be added to the Input Table.

String
field_type (Required)

The field type used in the creation of the new field.

  • TEXT — Names or other textual qualities.
  • FLOAT — Numeric values with fractional values within a specific range.
  • DOUBLE — Numeric values with fractional values within a specific range.
  • SHORT — Numeric values without fractional values within a specific range; coded values.
  • LONG — Numeric values without fractional values within a specific range.
  • DATE — Date and/or Time.
  • BLOB — Images or other multimedia.
  • RASTER — Raster images.

String
field_precision (Optional)

Describes the number of digits that can be stored in the field. All digits are counted no matter what side of the decimal they are on.

If the input table is a personal or file geodatabase the field precision value will be ignored.

Long
field_scale (Optional)

Sets the number of decimal places stored in a field. This parameter is only used in Float and Double data field types.

If the input table is a personal or file geodatabase the field scale value will be ignored.

Long
field_length (Optional)

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 on fields of type text or blob.

Long
field_alias (Optional)

The alternate name given to the field name. This name is used to give more descriptive names to cryptic field names. The field alias parameter only applies to geodatabases and coverages.

String
field_is_nullable (Optional)

A geographic feature where there is no associated attribute information. These are different from zero or empty fields and are only supported for fields in a geodatabase.

  • NON_NULLABLE — The field will not allow null values.
  • NULLABLE — The field will allow null values. This is the default.

Boolean
field_is_required (Optional)

Specifies whether the field being created is a required field for the table; Only supported for fields in a geodatabase.

  • NON_REQUIRED — The field is not a required field. This is the default.
  • REQUIRED — The field is a required field. This means new records must contain a value for the field. Required fields are permanent and can not be deleted.

Boolean
field_domain (Optional)

Used to constrain the values allowed in any particular attribute for a table, feature class, or subtype in a geodatabase. You must specify the name of an existing domain for it to be applied to the field.

String

Data types for geoprocessing tool parameters


Script example

import arcgisscripting
gp = arcgisscripting.create()

# Set a default workspace
gp.workspace = "c:\\test_data"

# Set a toolbox
gp.toolbox = "management"

try:
    # Add a field to this shapefile, of type LONG
    gp.addfield ("harvestable.shp", "year", "long", "9")

    # Adds a geodatabase stand-alone feature class of type LONG
    gp.addfield ("redlands.mdb\streets", "ref_ID", "long", "9", "#", "#", "refcode", "NULLABLE", "REQUIRED", "#")

except:
    # If an error occurs when running Addfield, print out the error message.
    print gp.GetMessages(2)

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.