Index

摘要

索引对象包含有关表索引的信息。存在两种索引类型:空间与属性。空间索引存在于要素类的 shape 字段中。

说明

无法直接创建索引对象。可通过 ListIndexesDescribe 功能访问索引对象。

属性

属性说明数据类型
fields
(只读)

索引字段对象的 Python 列表。

Field
isAscending
(只读)

isAscending 状态:索引按升序排序时为真。

Boolean
isUnique
(只读)

isUnique 状态:索引唯一时为真。

Boolean
name
(只读)

索引的名称。

String

代码示例

索引示例

显示指定表的索引属性。

import arcpy

feature_class = "c:/data/well.shp"

# Create a list of indexes using the ListIndexes function
indexes = arcpy.ListIndexes(feature_class)

# Iterate through the list of indexes
for index in indexes:
    # Print index properties
    print("Name: {0}".format(index.name))
    print("\tType            : {0}".format(index.isAscending))
    print("\tScale           : {0}".format(index.isUnique))
    print("\tNumber of fields: {0}".format(len(index.fields)))

相关主题