ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

升级地理数据库

  • 描述
  • 使用方法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

将地理数据库升级到最新 ArcGIS 版本以使用新的功能。

您必须将当前版本的 ArcGIS Desktop 或 ArcGIS Server 安装到您将要运行升级的计算机上。对于企业级地理数据库,您必须直接连接到地理数据库才可升级;不能通过 ArcSDE 服务进行连接。

使用方法

  • 升级地理数据库工具接受个人地理数据库、文件地理数据库或 .sde 连接文件作为输入。

  • 您不能从 ArcGIS Desktop Basic 中升级桌面、工作组级或企业级地理数据库。

  • 在升级您的企业级地理数据库之前,请确保您已经对正在使用的数据库管理系统执行了所需的准备工作,包括创建数据库的备份。

    • 在 Db2 中升级地理数据库
    • 在 Informix 中升级地理数据库
    • 在 Oracle 中升级地理数据库
    • 在 PostgreSQL 中升级地理数据库
    • 在 SQL Server 中升级地理数据库

  • 要确定地理数据库版本,右键单击目录树中的地理数据库,然后单击属性。常规选项卡中的升级状态部分显示了 ArcGIS 的地理数据库版本,并指明地理数据库是否可以升级到最新的 ArcGIS 版本。
  • 您必须选中执行必要的先行检查参数或升级地理数据库参数,或者您可以同时选中这两个参数。不选中任何参数将导致错误。
  • Esri 建议您在升级地理数据库之前先使用先决条件检查来确定您的地理数据库是否做好升级准备。如果有任何先决条件未得到满足,此工具会在结果窗口中记录一条错误,并且不会升级地理数据库。 这可以使您不会在升级过程中仅因为某个先决条件未得到满足而中断整个升级过程。如果任何检查出现失败,您必须先对存在的问题进行更正,然后再重新启动升级过程。
  • 不支持对地理数据库的测试版本进行升级。
  • 执行必要的先行检查选项针对每个类型的地理数据库执行不同检查。针对个人和文件地理数据库,确定以下情况:
    • 地理数据库是否为只读。
    • 是否有其他用户连接到此地理数据库。
    • 当前连接是否未在地理数据库中编辑数据。
    • 当前地理数据库系统表中的所有信息是否可以打开。
    • 对于桌面、工作组级和企业级地理数据库,确定是否满足以下条件:
      • 连接的用户具有升级地理数据库所需的适当权限。
      • 连接的用户是否未在地理数据库中编辑数据。
      • 是否有其他用户连接到此地理数据库。
      • 是否为数据库启用了对 XML 数据类型的支持。
      • 当前地理数据库系统表中的所有信息是否可以打开。
      • 对于 PostgreSQL 和 Oracle 中的地理数据库,它会检测数据库是否可以访问 ST_Geometry 库的当前版本。
      • 对于 Oracle 中采用用户方案的地理数据库,它会检测是否升级了主地理数据库。
  • 不再支持存储在地理数据库中的定位器。如果将定位器存储有要进行升级的地理数据库中,则必须先从 ArcGIS Desktop 10.4.1 或较早版本连接到地理数据库,然后移除该定位器。

语法

arcpy.management.UpgradeGDB(input_workspace, input_prerequisite_check, input_upgradegdb_check)
参数说明数据类型
input_workspace

指定要进行升级的地理数据库。当升级桌面、工作组级或企业级地理数据库时,指定以地理数据库管理员身份连接到地理数据库的数据库连接文件 (.sde)

Workspace
input_prerequisite_check

指定是否在升级地理数据库之前执行先决条件检查。

  • NO_PREREQUISITE_CHECK —不执行先决条件检查。
  • PREREQUISITE_CHECK —执行先决条件检查。这是默认设置。
Boolean
input_upgradegdb_check

指定是否升级地理数据库。

  • NO_UPGRADE —不进行升级。
  • UPGRADE —进行升级。这是默认设置。
Boolean

派生输出

名称说明数据类型
out_workspace

更新的地理数据库。

工作空间

代码示例

UpgradeGeodatabase 示例 1(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用 UpgradeGDB 函数升级文件地理数据库:

import arcpy
default_gdb = "C:/temp/Default.gdb"
arcpy.UpgradeGDB_management(default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
UpgradeGeodatabase 示例 2(独立脚本)

以下独立 Python 脚本演示了如何在 Python 脚本中使用 UpgradeGDB 函数升级文件地理数据库:

# Description: upgrade a geodatabase
 
# Import arcpy module
import arcpy
# Local variables:
default_gdb = "C:/temp/Default.gdb"
# Process: Upgrade Geodatabase
arcpy.UpgradeGDB_management(default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
UpgradeGeodatabase 示例 3(独立脚本)

以下独立 Python 脚本演示了如何在 Python 脚本中通过现有 .sde 连接文件使用 UpgradeGDB 函数升级企业级地理数据库:

# Description: upgrade a geodatabase
# Import arcpy module
import arcpy
# Local variables:
default_gdb = "C:/connections/gdbconnection.sde"
# Process: Upgrade Geodatabase
arcpy.UpgradeGDB_management(default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
UpgradeGeodatabase 示例 4(独立脚本)

以下独立 Python 脚本演示了如何在 Python 脚本中使用 UpgradeGDB 函数升级企业级地理数据库:

"""
Name: upgrade_gdb.py
Description: Provide connection information to an Enterprise geodatabase 
and upgrade the geodatabase
Type upgrade_gdb.py -h or upgrade_gdb.py --help for usage
"""

# Import system modules
import arcpy
import os
import optparse
import sys


# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 2.0; valid for 10.1 only")

#Define help and options
parser.add_option ("--DBMS", dest="Database_type", type="choice", choices=['SQLSERVER', 'ORACLE', 'POSTGRESQL', 'DB2','INFORMIX','DB2ZOS',''], default="", help="Type of enterprise DBMS:  SQLSERVER, ORACLE, or POSTGRESQL.")
parser.add_option ("-i", dest="Instance", type="string", default="", help="DBMS instance name")
parser.add_option ("--auth", dest="account_authentication", type ="choice", choices=['DATABASE_AUTH', 'OPERATING_SYSTEM_AUTH'], default='DATABASE_AUTH', help="Authentication type options (case-sensitive):  DATABASE_AUTH, OPERATING_SYSTEM_AUTH.  Default=DATABASE_AUTH")
parser.add_option ("-u", dest="User", type="string", default="", help="Geodatabase administrator user name")
parser.add_option ("-p", dest="Password", type="string", default="", help="Geodatabase administrator password")
parser.add_option ("--upgrade", dest="Upgrade", type="choice", choices=['TRUE', 'FALSE'], default="FALSE", help="Upgrade Options (case-sensitive):  TRUE=Perform Pre-requisite check and upgrade geodatabase, FALSE=Perform Pre-requisite check only.  Default=FALSE")                   
parser.add_option ("-D", dest="Database", type="string", default="none", help="Database name:  Not required for Oracle")


# Check if value entered for option
try:
	(options, args) = parser.parse_args()

	
#Check if no system arguments (options) entered
	if len(sys.argv) == 1:
		print("%s: error: %s\n" % (sys.argv[0], "No command options given"))
		parser.print_help()
		sys.exit(3)

	#Usage parameters for spatial database connection to upgrade
	account_authentication = options.account_authentication.upper()
	username = options.User.lower() 
	password = options.Password	
	do_upgrade = options.Upgrade
	database = options.Database.lower()
	database_type = options.Database_type.upper()
	instance = options.Instance
	
	if (database_type == ""):
		print("\nDatabase type must be specified!\n")
		parser.print_help()
		sys.exit(3)
	
	if (database_type == "SQLSERVER"):
		database_type = "SQL_SERVER"
	
	# Get the current product license
	product_license=arcpy.ProductInfo()
	
	# Checks required license level to upgrade
	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
		print("\n" + product_license + " license found!" + "  Enterprise geodatabase upgrade requires an ArcGIS Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS Server license.")
		sys.exit("Re-authorize ArcGIS before upgrading.")
	else:
		print("\n" + product_license + " license available!  Continuing to upgrade...")
		arcpy.AddMessage("+++++++++")
	
	# Local variables
	instance_temp = instance.replace("\\","_")
	instance_temp = instance_temp.replace("/","_")
	instance_temp = instance_temp.replace(":","_")
	Conn_File_NameT = instance_temp + "_" + database + "_" + username     
	
	if os.environ.get("TEMP") == None:
		temp = "c:\\temp"	
	else:
		temp = os.environ.get("TEMP")
	
	if os.environ.get("TMP") == None:
		temp = "/usr/tmp"		
	else:
		temp = os.environ.get("TMP")  
	
	Connection_File_Name = Conn_File_NameT + ".sde"
	Connection_File_Name_full_path = temp + os.sep + Conn_File_NameT + ".sde"
	
	# Check for the .sde file and delete it if present
	arcpy.env.overwriteOutput=True
	if os.path.exists(Connection_File_Name_full_path):
		os.remove(Connection_File_Name_full_path)
	
	print("\nCreating Database Connection File...\n")
	# Process: Create Database Connection File...
	# Usage:  out_file_location, out_file_name, DBMS_TYPE, instnace, database, account_authentication, username, password, save_username_password(must be true)
	arcpy.CreateDatabaseConnection_management(out_folder_path=temp, out_name=Connection_File_Name, database_platform=database_type, instance=instance, database=database, account_authentication=account_authentication, username=username, password=password, save_user_pass="TRUE")
        for i in range(arcpy.GetMessageCount()):
		if "000565" in arcpy.GetMessage(i):   #Check if database connection was successful
			arcpy.AddReturnMessage(i)
			arcpy.AddMessage("\n+++++++++")
			arcpy.AddMessage("Exiting!!")
			arcpy.AddMessage("+++++++++\n")
			sys.exit(3)            
		else:
			arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
			
	# Check whether geodatabase needs upgrade
	isCurrent = arcpy.Describe(Connection_File_Name_full_path).currentRelease
	
	if isCurrent == True:
		print("The geodatabase is already at the current release and cannot be upgraded!")
		sys.exit("Upgrade did not run.")
	
	
	# Process: Upgrade geodatabase...
	try:
		if do_upgrade.lower() == "true":
			print("Upgrading Geodatabase...\n")
			arcpy.UpgradeGDB_management(input_workspace=Connection_File_Name_full_path, input_prerequisite_check="PREREQUISITE_CHECK", input_upgradegdb_check="UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
		else:
			print("Running Pre-Requisite Check...\n")
			arcpy.UpgradeGDB_management(input_workspace=Connection_File_Name_full_path, input_prerequisite_check="PREREQUISITE_CHECK", input_upgradegdb_check="NO_UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
		
	        
	except:
		for i in range(arcpy.GetMessageCount()):
			arcpy.AddReturnMessage(i)
		
	if os.path.exists(Connection_File_Name_full_path):
		os.remove(Connection_File_Name_full_path)
	
#Check if no value entered for option	
except SystemExit as e:
	if e.code == 2:
		parser.usage = ""
		print("\n")
		parser.print_help()
		parser.exit(2)

环境

  • 当前工作空间

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题

  • “地理数据库管理”工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明