Add Field (Data Management) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
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
See ArcGIS data types for a detailed explanation of field types.
A field of type raster allows you to have a raster image as an attribute. It is stored within or alongside the geodatabase. This is helpful when a picture is the best way to describe a feature. Precision, scale and length can not be set for fields of type raster.
Coverages, standalone tables, feature classes from ArcSDE and personal or file geodatabases, layer files, raster catalogs, and shapefiles will work as valid input for this command. VPF and CAD feature data overlays will not work, since they are read-only formats that are not native to ArcGIS.
The added field will always be displayed at the end of the table.
The Field Length parameter is only applicable on fields of type text or blob.
For coverages, 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.
For geodatabases, if field type defines a character or number <null> is inserted into each record if the FieldIsNullible parameter default is accepted.
A shapefile does not support alias for fields, so you cannot add a field alias to a shapefile.
It is only possible to add a field that is not nullable to an empty geodatabase feature class or table. Add Field cannot add a field that is not nullable when the rows already exist.
The Field Domain parameter can call an existing domain from a feature class in a personal, file or SDE geodatabase.
The precision and scale of a field describe the maximum size and precision of data that can be stored in the field. The precision describes the number of digits that can be stored in the field and the scale describes the number of decimal places for float and double fields. For example, if the field value is 54.234 then scale = 3 and precision = 5.
Use the following guidelines for choosing the correct field type for a given precision and scale:
When creating a new field in a geodatabase feature class or table, you can specify the field's type, but not it's precision, and scale. Even if the dialog allows you to add a value for precision or scale it will be ignored during execution.
The name of an existing domain must be specified for the Field Domain parameter. Enter invalid domain names or values will not cause the tool to fail but it will be ignored and no domain will be set for the field.
Fields set as REQUIRED are permanent and you will not be able to delete them with future processing. To allow for deletion at a later time set the field to NON_REQUIRED (the default).
For more information about adding fields see, Adding and deleting fields or About tabular data sources
For more information about the RASTER type option see, Raster datasets as attributes
The following environment affects this tool: workspace.
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.
|
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.
|
Boolean |
{NON_REQUIRED | REQUIRED} |
Specifies whether the field being created is a required field for the table; Only supported for fields in a geodatabase.
|
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 |
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.
|
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.
|
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.
|
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 |
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)