Table To Domain (Data Management)
Summary
Creates or updates a coded value domain with values from a table.
Usage
-
A domain can also be created with the Create Domain tool.
-
Workspace domains can also be managed in ArcCatalog or the Catalog window. Domains can be created and modified through the Domains tab on the Database Properties dialog box.
Syntax
Parameter | Explanation | Data Type |
in_table |
The database table from which to derive domain values. | Table View |
code_field |
The field in the database table from which to derive domain code values. | Field |
description_field |
The field in the database table from which to derive domain description values. | Field |
in_workspace |
The workspace that contains the domain to be created or updated. | Workspace |
domain_name |
The name of the domain to be created or updated. | String |
domain_description (Optional) |
The description of the domain to be created or updated. Domain descriptions of existing domains are not updated. | String |
update_option (Optional) |
If the domain already exists, specifies how the domain will be updated.
| String |
Code Sample
The following Python window script demonstrates how to use the TableToDomain function in immediate mode.
import arcpy from arcpy import env env.workspace = "C:/data" arcpy.TableToDomain_management ("diameter.dbf", "code", "descript", "montgomery.gdb", "diameters", "Valid pipe diameters")
This stand-alone script uses the TableToDomain function as part of a workflow.
#Name: TableToDomain.py # Purpose: Update an attribute domain to constrain valid pipe material values #Author: ESRI # Import system modules import arcpy from arcpy import env try: # Set the workspace (to avoid having to type in the full path to the data every time) env.workspace = "C:/data" #Set local parameters domTable = "diameter.dbf" codeField = "code" descField = "descript" dWorkspace = "Montgomery.gdb" domName = "diameters" domDesc = "Valid pipe diameters" # Process: Create a domain from an existing table arcpy.TableToDomain_management(domTable, codeField, descField, dWorkspace, domName, domDesc) except Exception, e: # If an error occurred, print line number and error message import traceback, sys tb = sys.exc_info()[2] print "Line %i" % tb.tb_lineno print e.message