Skip to main content

维护全限定的字段名 (环境设置)

支持“维护全限定的字段名”环境的工具将使用此设置来区分限定的字段名和未限定的字段名。 限定的字段名是要素类或表中的这样一些字段名称,在它们的字段名称后会附加原始要素类或表的名称。 使用连接数据时,会涉及此设置。

用法说明

  • 默认限定的输出表字段命名结构为“表名.字段名”。 当未限定时,输出表或要素类中的字段将始终用格式字段名命名。

  • 当限定的字段名可能超出允许的字段名宽度时,应将环境设为未限定 - 例如,连接 shapefile 时。 Shapefile 字段将截短为八个字符。

  • 当工具参数中包含字段映射时(“转换”工具箱的许多工具中都包括),字段名自动设置为未限定,因此无需设置该环境。

对话框语法

  • Checked—输出字段名将包括表名。 这是默认设置。

  • Unchecked—输出字段名不包括表名。

Python 语法

arcpy.env.qualifiedFieldNames = qualified_field_names

名称 说明

qualified_field_names

  • True—输出字段名将包括表名。 也可以使用 QUALIFIED 关键字设置该参数。 这是默认设置。

  • False—输出字段名不包括表名。 也可以使用 UNQUALIFIED 关键字设置该参数。

脚本语法

# Name: addjoin.py
# Purpose: Join a table to a feature class and have the output unqualified

# Import system modules
import arcpy

# Set environment settings
arcpy.env.workspace = "C:/data"
arcpy.env.qualifiedFieldNames = False

# Set local variables
inFeatures = "Habitat_Analysis.gdb/vegtype"
layerName = "veg_layer"
joinTable = "vegtable.dbf"
joinField = "HOLLAND95"
expression = "vegtable.HABITAT = 1"
outFeature = "Habitat_Analysis.gdb/vegjoin"

# Create a feature layer from the vegtype feature class
arcpy.management.MakeFeatureLayer(inFeatures, layerName)

# Join the feature layer to a table
arcpy.management.AddJoin(layerName, joinField, joinTable, joinField)

# Copy the layer to a new permanent feature class
# Output fields are unqualified, so the field name will
# not contain the origin table
arcpy.management.CopyFeatures(layerName, outFeature)