升级地理数据库(Geodatabase) (Data Management)
汇总
将地理数据库升级到最新版本,以利用最新版本的 ArcGIS 所提供的各种新功能。有效的输入参数可以是个人地理数据库或文件地理数据库,也可以是 ArcSDE 地理数据库的 sde 连接文件或连接信息。
您必须在要执行升级操作的计算机上安装当前版本的 ArcGIS Desktop(ArcEditor 或 ArcInfo 许可级别)、具有 Geodatabase Update 扩展模块的 ArcGIS Engine Runtime 或者 ArcGIS Server 标准版或高级版。对于 ArcSDE 地理数据库,必须建立与地理数据库的直连才能进行升级。用于支持旧版地理数据库的直连驱动程序会随 ArcGIS Desktop、ArcGIS Engine 和 ArcGIS Server 一起自动安装。
用法
升级 ArcSDE 地理数据库之前,请确保已阅读并执行了以下相应主题中的步骤:
- 要确定地理数据库版本,可在目录 窗口中右键单击地理数据库,然后单击属性。常规选项卡中的升级状态区域将显示 ArcGIS 的地理数据库版本,并指明地理数据库是否可以升级到最新版本,以利用各种新功能。
- 执行必要的先行检查参数和升级地理数据库(Geodatabase) 参数应至少选中一个。若均未选中,将会产生错误。
- Esri 建议在升级地理数据库之前先使用先行检查来确定您的地理数据库是否做好升级准备。如果有任何先决条件未得到满足,此工具会在结果 窗口中记录一条错误,并且不会升级地理数据库。这可以使您不会在升级过程中仅因为某个先决条件未得到满足而中断整个升级过程。如果任何检查出现失败,您必须先对存在的问题进行更正,然后再重新启动升级过程。
- 不支持对地理数据库的测试版本进行升级。
- 升级地理数据库后,先前版本的 ArcGIS 将无法打开该地理数据库,因为较早版本的 ArcGIS 无法读取较新版本的地理数据库。
- 执行必要的先行检查选项会根据升级的地理数据库类型来进行不同的检查。对于个人地理数据库和文件地理数据库,其会检查
- 地理数据库是否为只读。
- 是否有其他用户连接到此地理数据库。
- 当前连接是否未在地理数据库中编辑数据。
- 当前地理数据库系统表中的所有信息是否可以打开。
- 对于 ArcSDE 地理数据库,其会检查
- 连接的用户是否具有执行升级所需的适当权限。
- 连接的用户是否未在地理数据库中编辑数据。
- 是否有其他用户连接到此地理数据库。
- 是否为数据库启用了对 XML 数据类型的支持。
- 当前地理数据库系统表中的所有信息是否可以打开。
- 对于 PostgreSQL 和 Oracle 中的地理数据库,它会检测数据库所在位置中的 ST_Geometry 库是否是当前的。
- 对于 Oracle 中采用用户方案的地理数据库,它会检测是否升级了主地理数据库。
语法
| 参数 | 说明 | 数据类型 |
input_workspace |
要升级的个人地理数据库、文件地理数据库或 ArcSDE 地理数据库 | Workspace |
input_prerequisite_check |
指定是否在升级地理数据库之前执行先行检查
| Boolean |
input_upgradegdb_check |
指定是否进行升级
| Boolean |
代码示例
以下 Python 窗口脚本演示了如何在即时模式下使用 UpgradeGDB 函数升级文件地理数据库:
import arcpy Output_Workspace = "C:\\temp\\Default.gdb" Default_gdb = "C:\\temp\\Default.gdb" arcpy.UpgradeGDB_management(Default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
以下独立 Python 脚本演示了如何在 Python 脚本中使用 UpgradeGDB 函数升级文件地理数据库:
# Description: upgrade a geodatabase # Import arcpy module import arcpy # Local variables: Output_Workspace = "C:\\temp\\Default.gdb" Default_gdb = "C:\\temp\\Default.gdb" # Process: Upgrade Geodatabase arcpy.UpgradeGDB_management(Default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
以下独立 Python 脚本演示了如何在 Python 脚本中通过现有 .sde 连接文件使用 UpgradeGDB 函数升级 ArcSDE 地理数据库:
# Description: upgrade a geodatabase # Import arcpy module import arcpy # Local variables: Output_Workspace = "C:\\Documents and Settings\<user>\Application Data\ESRI\ArcCatalog\Connection to gdb.sde" Default_gdb = "C:\\Documents and Settings\<user>\Application Data\ESRI\ArcCatalog\Connection to gdb.sde" # Process: Upgrade Geodatabase arcpy.UpgradeGDB_management(Default_gdb, "PREREQUISITE_CHECK", "UPGRADE")
以下独立 Python 脚本演示了如何在 Python 脚本中使用 UpgradeGDB 函数升级 Oracle 中的 ArcSDE 地理数据库:
"""
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, os, optparse, sys
# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0; valid for 10.0 and 10.1 release")
#Define help and options
parser.add_option ("-s", dest="Server", type="string", default="", help="RDBMS server name")
parser.add_option ("-i", dest="Service", type="string", default="", help="Use direct connection syntax")
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 ("-v", dest="Version", type="string", help="ArcSDE version name")
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
server = options.Server
service = options.Service
account_authentication = options.account_authentication.upper()
username = options.User.lower()
password = options.Password
version = options.Version.upper()
do_upgrade = options.Upgrade
database = options.Database.lower()
# 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 ArcEditor, ArcInfo, ArcGIS Engine Geodatabase Update, or ArcGIS Server license."
sys.exit("Re-authorize ArcGIS before upgrading.")
else:
print "\n" + product_license + " license available! Continuing to upgrade..."
arcpy.AddMessage("+++++++++")
# Check if direct connection
if service.find(":") <> -1: #This is direct connect
ServiceConnFileName = service.replace(":", "")
ServiceConnFileName = ServiceConnFileName.replace(";", "")
ServiceConnFileName = ServiceConnFileName.replace("=", "")
ServiceConnFileName = ServiceConnFileName.replace("/", "")
ServiceConnFileName = ServiceConnFileName.replace("\\", "")
else:
arcpy.AddMessage("\n+++++++++")
arcpy.AddMessage("Exiting!!")
arcpy.AddMessage("+++++++++")
sys.exit("\nSyntax for a direct connection in the Service parameter is required for geodatabase upgrade.")
# Local variables
Conn_File_NameT = server + "_" + ServiceConnFileName + "_" + 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 = temp + os.sep + Conn_File_NameT + ".sde"
# Check for the .sde file and delete it if present
arcpy.env.overwriteOutput=True
# Variables defined within the script; other variable options commented out at the end of the line
saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
print "\nCreating ArcSDE Connection File...\n"
# Process: Create ArcSDE Connection File...
# Usage: out_folder_path, out_name, server, service, database, account_authentication, username, password, save_username_password, version, save_version_info
arcpy.CreateArcSDEConnectionFile_management(temp, Conn_File_NameT, server, service, database, account_authentication, username, password, saveUserInfo, version, saveVersionInfo)
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")
# Process: Upgrade geodatabase...
try:
if do_upgrade.lower() == "true":
print "Upgrading Geodatabase...\n"
arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_CHECK", "UPGRADE")
for i in range(arcpy.GetMessageCount()):
arcpy.AddReturnMessage(i)
arcpy.AddMessage("+++++++++\n")
else:
print "Running Pre-Requisite Check...\n"
arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_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)
#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)以下独立 Python 脚本演示了如何在 Python 脚本中使用 UpgradeGDB 函数升级 IBM DB2、Informix、Microsoft SQL Server 或 PostgreSQL 中的 ArcSDE 地理数据库:
"""
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, os, optparse, sys
# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0; valid for 10.0 and 10.1 release")
#Define help and options
parser.add_option ("-s", dest="Server", type="string", default="", help="RDBMS server name")
parser.add_option ("-i", dest="Service", type="string", default="", help="Use direct connection syntax")
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 ("-v", dest="Version", type="string", help="ArcSDE version name")
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
server = options.Server
service = options.Service
account_authentication = options.account_authentication.upper()
username = options.User.lower()
password = options.Password
version = options.Version.upper()
do_upgrade = options.Upgrade
database = options.Database.lower()
# 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 ArcEditor, ArcInfo, ArcGIS Engine Geodatabase Update, or ArcGIS Server license."
sys.exit("Re-authorize ArcGIS before upgrading.")
else:
print "\n" + product_license + " license available! Continuing to upgrade..."
arcpy.AddMessage("+++++++++")
# Check if direct connection
if service.find(":") <> -1: #This is direct connect
ServiceConnFileName = service.replace(":", "")
ServiceConnFileName = ServiceConnFileName.replace(";", "")
ServiceConnFileName = ServiceConnFileName.replace("=", "")
ServiceConnFileName = ServiceConnFileName.replace("/", "")
ServiceConnFileName = ServiceConnFileName.replace("\\", "")
else:
arcpy.AddMessage("\n+++++++++")
arcpy.AddMessage("Exiting!!")
arcpy.AddMessage("+++++++++")
sys.exit("\nSyntax for a direct connection in the Service parameter is required for geodatabase upgrade.")
# Local variables
Conn_File_NameT = server + "_" + ServiceConnFileName + "_" + 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 = temp + os.sep + Conn_File_NameT + ".sde"
# Check for the .sde file and delete it if present
arcpy.env.overwriteOutput=True
# Variables defined within the script; other variable options commented out at the end of the line
saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
print "\nCreating ArcSDE Connection File...\n"
# Process: Create ArcSDE Connection File...
# Usage: out_folder_path, out_name, server, service, database, account_authentication, username, password, save_username_password, version, save_version_info
arcpy.CreateArcSDEConnectionFile_management(temp, Conn_File_NameT, server, service, database, account_authentication, username, password, saveUserInfo, version, saveVersionInfo)
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")
# Process: Upgrade geodatabase...
try:
if do_upgrade.lower() == "true":
print "Upgrading Geodatabase...\n"
arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_CHECK", "UPGRADE")
for i in range(arcpy.GetMessageCount()):
arcpy.AddReturnMessage(i)
arcpy.AddMessage("+++++++++\n")
else:
print "Running Pre-Requisite Check...\n"
arcpy.UpgradeGDB_management(Connection_File_Name, "PREREQUISITE_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)
#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)