ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 合约
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

重建索引

  • 摘要
  • 用法
  • 语法
  • 代码实例
  • 环境
  • 许可信息

摘要

此工具用于在数据库以及企业级、工作组和桌面地理数据库中重新构建现有属性或空间索引。在企业级、工作组和桌面地理数据库中,还可以重新构建版本化数据集的状态表、state_lineage 地理数据库系统表以及增量表的索引。 过期的索引可能会降低查询的性能。

用法

  • 数据必须来自企业级、工作组或桌面地理数据库。此工具不适用于文件或个人地理数据库。
  • 执行数据加载、删除、更新和压缩操作后,重新构建索引是非常重要的。
  • 此工具可重新构建版本化和启用存档的地理数据库中基表、增量表和存档表的属性和空间索引。
  • 包括系统表参数用于决定是否在指定地理数据库中重新构建状态表和状态谱系表的索引。未选择该选项时,将不会重新构建这些表的索引。如果未选中包括系统表参数,则在待重建索引的数据集中至少需要选择一个数据集才能运行该工具。
  • 待重建索引的数据集参数的添加值按钮仅可在模型构建器中使用。在模型构建器中,如果先前的工具尚未运行或其派生数据不存在,则可能不会使用值来填充待重建索引的数据集参数。添加值按钮可用于添加所需值,以完成对话框并继续构建模型。

语法

RebuildIndexes_management (input_database, include_system, {in_datasets}, {delta_only})
参数说明数据类型
input_database

到数据库或地理数据库(包含要为其重建索引的数据)的连接(.sde 文件)。

Workspace
include_system

指示是否重新构建状态和状态谱系表的索引。

注:

要成功执行此选项,您必须在为 input_database 指定的连接文件中以地理数据库管理员身份进行连接。

此选项仅适用于地理数据库。如果连接到了数据库,将忽略此选项。

  • NO_SYSTEM — 不会重新构建状态和状态谱系表的索引。这是默认设置。
  • SYSTEM — 将重新构建状态和状态谱系表的索引。
Boolean
in_datasets
[in_datasets,...]
(可选)

要重新构建索引的数据集的名称。数据集名称使用指向 input_database 的相对路径;不能输入完整路径。

Dataset
delta_only
(可选)

指示如何在选定数据集中重新构建索引。如果 in_datasets 为空,则此选项不起作用。

此选项仅适用于地理数据库。如果输入工作空间为数据库,此选项将被忽略。

  • ALL —将针对选定数据库的所有索引重新构建索引。包括空间索引以及用户创建的属性索引和数据集的所有地理数据库维护索引。
  • ONLY_DELTAS —将只对选定数据集的增量表重新构建索引。选定数据集的业务表不常更新且增量表中编辑量较大的情况下可使用此选项。这是默认设置。
Boolean

代码实例

RebuildIndexes 示例 1(Python 窗口)

以下示例演示了如何在 ArcGIS 的 Python 窗口中重新构建索引。

# Import system modules
import arcpy

arcpy.RebuildIndexes_management("c:/Connections/GDB@DC@server.sde", "NO_SYSTEM","db1.GDB.Roads;db1.GDB.Parcels", "ALL")
RebuildIndexes 示例 2(独立脚本)

以下示例演示了如何在独立脚本中重新构建索引。

# Name: RebuildIndexes.py
# Description: rebuilds indexes on delta tables for all datasets in an
# enterprise geodatabase

# Import system modules
import arcpy, os

# set workspace
workspace = arcpy.GetParameterAsText(0)

# set the workspace environment
arcpy.env.workspace = workspace

# NOTE: Rebuild indexes can accept a Python list of datasets.

# Get a list of all the datasets the user has access to.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses() + arcpy.ListRasters()

# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets("", "Feature"):
    arcpy.env.workspace = os.path.join(workspace,dataset)
    dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()

# reset the workspace
arcpy.env.workspace = workspace

# Get the user name for the workspace
userName = arcpy.Describe(workspace).connectionProperties.user.lower()

# remove any datasets that are not owned by the connected user.
userDataList = [ds for ds in dataList if ds.lower().find(".%s." % userName) > -1]

# Execute rebuild indexes
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.RebuildIndexes_management(workspace, "NO_SYSTEM", userDataList, "ALL")
print('Rebuild Complete')

环境

  • 当前工作空间

相关主题

  • “地理数据库管理”工具集概述
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明