ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

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

创建企业级地理数据库

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

摘要

创建企业级地理数据库工具可创建数据库、存储位置,以及作为地理数据库管理员和地理数据库所有者的数据库用户。其功能会根据具体使用的数据库管理系统而有所不同。此工具授予地理数据库管理员创建地理数据库以及在数据库中创建地理数据库所需的权限。

用法

  • 下表列出了对于每种类型的数据库管理系统 (DBMS),该工具可实现的功能:

    功能DBMS

    创建数据库

    PostgreSQL 和 Microsoft SQL Server

    创建表空间

    Oracle

    在数据库中创建地理数据库管理员用户

    Oracle、PostgreSQL 和 SQL Server

    请注意,如果您创建 sde 方案地理数据库,则此工具仅在 SQL Server 中创建用户。

    授予地理数据库管理员创建地理数据库、升级地理数据库和取消数据库连接所需的权限

    Oracle 和 PostgreSQL

    授予地理数据库管理员创建地理数据库和取消数据库连接所需的权限

    SQL Server(如果创建 sde 方案地理数据库)

    授予地理数据库管理员使用 Oracle Data Pump 导入数据所需的权限

    Oracle 12c

    在指定数据库中创建地理数据库

    Oracle、PostgreSQL 和 SQL Server

  • 用来创建地理数据库的计算机上必须安装有 ArcGIS Desktop(标准版或高级版)、具有 Geodatabase Update 扩展模块的 ArcGIS Engine Runtime 或者 ArcGIS Server。若您使用的是 Oracle 或 SQL Server,则必须在安装了 ArcGIS 客户端的计算机上安装并配置数据库管理系统客户端。

  • 您必须先配置 st_geometry 库,然后才能在 Oracle 中创建地理数据库。有关详细信息,请参阅在 Oracle 中创建地理数据库。

  • 必须将 st_geometry 库放置在 PostgreSQL 服务器上,然后才能在 PostgreSQL 中创建地理数据库。有关详细信息,请参阅在 Linux 上的 PostgreSQL 中创建地理数据库或在 Windows 上的 PostgreSQL 中创建地理数据库。

  • 该工具不支持 Amazon Relational Database Service for PostgreSQL、Amazon Relatioinal Database Service for SQL Server 或 Microsoft Azure SQL Database。

  • 一旦创建了地理数据库,则无法重命名存储该地理数据库的数据库。数据库名称存储在地理数据库系统表中,并用于完全限定表和要素类的名称;因此,使用数据库工具更改数据库名称会导致无法访问地理数据库数据。

语法

CreateEnterpriseGeodatabase_management (database_platform, instance_name, {database_name}, {account_authentication}, {database_admin}, {database_admin_password}, {sde_schema}, {gdb_admin_name}, {gdb_admin_password}, {tablespace_name}, authorization_file)
参数说明数据类型
database_platform

指定要连接以创建地理数据库的数据库管理系统的类型。

  • Oracle —指示您将连接到 Oracle 实例
  • PostgreSQL —指示您将连接到 PostgreSQL 数据库集群
  • SQL_Server —指示您将连接到 Microsoft SQL Server 实例
String
instance_name

对于 SQL Server,提供 SQL Server 的实例名。注意,不支持区分大小写或二进制排序规则 SQL Server 实例。

对于 Oracle,提供 TNS 名称或 Oracle Easy Connection 字符串。

对于 PostgreSQL,提供安装 PostgreSQL 的服务器的名称。

String
database_name
(可选)

该参数对 PostgreSQL 和 SQL Server 有效。您可以输入现有的、预先配置的数据库名称,也可以输入此工具要创建的数据库名称。

如果要使该工具在 SQL Server 中创建数据库,文件大小可与为 SQL Server 模型数据库定义的大小相同,或者对于 MDF 文件为 500 MB,对于 LDF 文件为 125 MB,取较大值。MDF 文件和 LDF 文件均可在数据库服务器上的默认 SQL Server 位置上创建。

如果要使该工具在 PostgreSQL 中创建数据库,则 template1 数据库将用作您数据库的模板。数据库名称使用小写字符。即使未输入小写格式,此工具也会将其转换为小写字符。

String
account_authentication
(可选)

指定数据库连接要使用的身份验证类型。

  • OPERATING_SYSTEM_AUTH —您为运行该工具的计算机提供的登录信息将用于验证数据库连接。 如果 DBMS 没有配置为允许操作系统身份验证,则身份验证将失败。
  • DATABASE_AUTH —在数据库中验证身份时必须提供有效的数据库用户名和密码。这是默认的身份验证方法。 如果 DBMS 没有配置为允许数据库身份验证,则身份验证将失败。
Boolean
database_admin
(可选)

如果使用数据库身份验证,请指定数据库管理员用户。对于 Oracle,请使用 sys 用户。对于 PostgreSQL,请指定具有超级用户身份的用户。对于 SQL Server,请指定具有 sysadmin 固定服务器角色的任何成员。

String
database_admin_password
(可选)

如果使用数据库身份验证,请输入数据库管理员密码。

Encrypted String
sde_schema
(可选)

该参数只与 SQL Server 相关,并指示地理数据库是在名为 sde 的用户方案中创建还是在数据库的 dbo 方案中创建。如果创建的是一个 dbo 方案地理数据库,连接的用户为 SQL Server 实例中的 dbo。

  • SDE_SCHEMA —地理数据库资料档案库存储在名为 sde 的用户方案中并归该用户所有。这是默认设置。
  • DBO_SCHEMA —地理数据库资料档案库存储在数据库的 dbo 方案中。
Boolean
gdb_admin_name
(可选)

如果使用的是 PostgreSQL,该值必须为 sde。如果 sde 登录角色不存在,此工具将在数据库集群中创建该登录角色并授予其超级用户状态。如果 sde 登录角色已存在,当其没有超级用户状态时,此工具将对其授予这一状态。此工具还会在数据库中创建 sde 方案并向公共角色授予对该方案的使用权限。

如果使用的是 Oracle,则默认值为 sde。如果要在现有主 sde 地理数据库内创建用户方案地理数据库,请指定拥有新地理数据库的用户名称。如果 DBMS 中不存在 sde 或其他用户,则创建企业级地理数据库工具将创建用户并授予其创建和升级地理数据库以及删除用户与 DBMS 之间连接所需的权限。如果在 Oracle 12c 数据库中运行此工具,则此工具还将授予使用 Oracle Data Pump 导入数据所需的权限。如果特定用户已经存在,则该工具将向此用户授予同样的权限。

如果使用的是 SQL Server 并指定了一个 sde 方案地理数据库,则该值必须为 sde。此工具将创建 sde 登录、数据库用户和方案,并授予其创建地理数据库以及删除与 SQL Server 实例之间连接所需的权限。如果指定了 dbo 方案,则不要为该参数提供值。

String
gdb_admin_password
(可选)

为地理数据库管理员用户提供密码。如果地理数据库管理员用户已经存在于 DBMS 中,输入的密码必须与现有密码相匹配。如果地理数据库管理员用户尚未存在,则为新用户输入一个有效的数据库密码。该密码必须符合 DBMS 强制的密码策略。

密码是一个加密字符串。

Encrypted String
tablespace_name
(可选)

该参数只对 Oracle 和 PostgreSQL DBMS 类型有效。对于 Oracle,请执行以下某项操作:

  • 提供一个现有表空间的名称。对于地理数据库管理员用户,此表空间将用作默认的表空间。
  • 为新表空间输入一个有效名称。此工具将在 Oracle 的默认存储位置上创建一个 400 MB 的表空间,并将其设置为地理数据库管理员的默认表空间。
  • 将表空间留空,之后此工具将在 Oracle 的默认存储位置上创建一个名为 SDE_TBS 的 400 MB 表空间。SDE_TBS 表空间将被设置为地理数据库管理员的默认表空间。

此工具不会在 PostgreSQL 中创建表空间。必须为用作数据库默认表空间的现有表空间提供名称,或者将此参数留空。如果将此参数留空,则工具会在 pg_default 表空间中创建一个数据库。

String
authorization_file

提供授权 ArcGIS Server 时创建的密钥代码文件的路径和文件名。此文件位于 Windows 的 \\Program Files\ESRI\License<release#>\sysgen 文件夹或 Linux 的 /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen 目录中。如果尚未执行此操作,则请授权 ArcGIS Server 来创建此文件。

您可能需要从 ArcGIS Server 计算机将密钥代码文件拷贝到工具可以访问的位置。

File

派生输出

名称说明数据类型
out_result

代码示例

CreateGeodatabase 示例 1

以下脚本可在 Oracle 数据库中创建地理数据库。它创建 sde 用户并为该 sde 用户创建默认表空间 sdetbs。密钥代码文件位于远程 Linux 服务器上。

#Import arcpy module
import arcpy
arcpy.CreateEnterpriseGeodatabase_management("ORACLE", "ora11g:1521/elf", "", "DATABASE_AUTH", "sys", "manager", "", "sde", "supersecret", "sdetbs", 
                                             "//myserver/mymounteddrive/myaccessibledirectory/keycodes")
CreateGeodatabase 示例 2

该脚本连接到 SQL Server 实例 (tor\ssinstance),在其中创建一个名为 sp_data 的数据库和一个 sde 方案数据库。使用操作系统身份验证建立连接。密钥代码文件位于远程 Windows 服务器上。

#Import arcpy module
import arcpy
arcpy.CreateEnterpriseGeodatabase_management("SQL_SERVER", "tor\ssinstance1", "sp_data", "OPERATING_SYSTEM_AUTH", "", "", "SDE_SCHEMA", "sde", "sde", 
                                             "", "//myserver/myaccessibledirectory/keycodes")
CreateGeodatabase 示例 3

该脚本连接到服务器上名为 feldspar 的 PostgreSQL 数据库集群。如同在现有表空间 gdbspace 中创建数据库 pggdb 那样来创建 sde 用户。密钥代码文件位于本地 Linux 服务器上。

#Import arcpy module import arcpy
arcpy.CreateEnterpriseGeodatabase_management("POSTGRESQL", "feldspar", "pggdb", "DATABASE_AUTH", "postgres", "averturis", "", "sde", "nomira", "gdbspace", 
                                             "//arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License/sysgen/keycodes")
CreateGeodatabase 示例 4(独立脚本)

以下独立 Python 脚本可以提供特定于使用选项的站点的信息。

"""
Name: create_enterprise_gdb.py
Description: Provide connection information to a DBMS instance and create an enterprise geodatabase.
Type  create_enterprise_gdb.py -h or create_enterprise_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 1.0 for " + arcpy.GetInstallInfo()['Version'] )

#Define help and options
parser.add_option ("--DBMS", dest="Database_type", type="choice", choices=['SQLSERVER', 'ORACLE', 'POSTGRESQL', ''], 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 ("-D", dest="Database", type="string", default="none", help="Database name:  Do not specify for Oracle")
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="Dbms_admin", type="string", default="", help="DBMS administrator user")
parser.add_option ("-P", dest="Dbms_admin_pwd", type="string", default="", help="DBMS administrator password")
parser.add_option ("--schema", dest="Schema_type", type="choice", choices=['SDE_SCHEMA', 'DBO_SCHEMA'], default="SDE_SCHEMA", help="Schema type  applies to geodatabases in SQL Server only. Type SDE_SCHEMA to create geodatabase in SDE schema or type DBO_SCHEMA to create geodatabase in DBO schema. Default=SDE_SCHEMA")
parser.add_option ("-u", dest="Gdb_admin", type="string", default="", help="Geodatabase administrator user name; Must always be sde for PostgreSQL, sde-schema geodatabases in SQL Server, and master sde geodatabase in Oracle")
parser.add_option ("-p", dest="Gdb_admin_pwd", type="string", default="", help="Geodatabase administrator password")
parser.add_option ("-t", dest="Tablespace", type="string", default="", help="Tablespace name; For PostgreSQL, type name of existing tablespace in which to store database. If no tablespace name specified, pg_default is used. For Oracle, type name of existing tablespace, or, if tablespace with specified name does not exist, it will be created and set as the default tablespace for the sde user. If no tablespace name is specified, SDE_TBS tablespace is created and set as sde user default. Tablespace name not supported for SQL Server.")
parser.add_option ("-l", dest="Authorization_file", type="string", default="", help="Full path and name of authorization file; file created when ArcGIS Server Enterprise authorized, and stored in \\Program Files\ESRI\License<release#>\sysgen on Windows or /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen on Linux")
# 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
	database_type = options.Database_type.upper()
	instance = options.Instance
	database = options.Database.lower()	
	account_authentication = options.Account_authentication.upper()
	dbms_admin = options.Dbms_admin
	dbms_admin_pwd = options.Dbms_admin_pwd
	schema_type = options.Schema_type.upper()
	gdb_admin = options.Gdb_admin
	gdb_admin_pwd = options.Gdb_admin_pwd	
	tablespace = options.Tablespace
	license = options.Authorization_file
	
	
	if (database_type == "SQLSERVER"):
		database_type = "SQL_SERVER"
	
	if( database_type ==""):	
		print(" \n%s: error: \n%s\n" % (sys.argv[0], "DBMS type (--DBMS) must be specified."))
		parser.print_help()
		sys.exit(3)		
		
	if (license == ""):
		print(" \n%s: error: \n%s\n" % (sys.argv[0], "Authorization file (-l) must be specified."))
		parser.print_help()
		sys.exit(3)			
	
	if(database_type == "SQL_SERVER"):
		if(schema_type == "SDE_SCHEMA" and gdb_admin.lower() != "sde"):
			print("\n%s: error: %s\n" % (sys.argv[0], "To create SDE schema on SQL Server, geodatabase administrator must be SDE."))
			sys.exit(3)
		if (schema_type == "DBO_SCHEMA" and gdb_admin != ""):
			print("\nWarning: %s\n" % ("Ignoring geodatabase administrator specified when creating DBO schema..."))
		if( account_authentication == "DATABASE_AUTH" and dbms_admin == ""):
			print("\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified with database authentication"))
			sys.exit(3)
		if( account_authentication == "OPERATING_SYSTEM_AUTH" and dbms_admin != ""):
			print("\nWarning: %s\n" % ("Ignoring DBMS administrator specified when using operating system authentication..."))
	else:
		if (schema_type == "DBO_SCHEMA"):
			print("\nWarning: %s %s, %s\n" % ("Only SDE schema is supported on", database_type, "switching to SDE schema..." ))
			
		if( gdb_admin.lower() == ""):
			print("\n%s: error: %s\n" % (sys.argv[0], "Geodatabase administrator must be specified."))
			sys.exit(3)

		if( gdb_admin.lower() != "sde"):
			if (database_type == "ORACLE"):
				print("\nGeodatabase admin user is not SDE, creating user schema geodatabase on Oracle...\n")
			else:
				print("\n%s: error: %s for %s.\n" % (sys.argv[0], "Geodatabase administrator must be SDE", database_type))
				sys.exit(3)
			
		if( dbms_admin == ""):
			print("\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified!"))
			sys.exit(3)

		if (account_authentication == "OPERATING_SYSTEM_AUTH"):
			print("Warning: %s %s, %s\n" % ("Only database authentication is supported on", database_type, "switching to database authentication..." ))

	# Get the current product license
	product_license=arcpy.ProductInfo()
	
	
	# Checks required license level
	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
		print("\n" + product_license + " license found!" + " Creating an enterprise geodatabase requires an ArcGIS Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS Server license.")
		sys.exit("Re-authorize ArcGIS before creating enterprise geodatabase.")
	else:
		print("\n" + product_license + " license available!  Continuing to create...")
		arcpy.AddMessage("+++++++++")
	
	
	try:
		print("Creating enterprise geodatabase...\n")
		arcpy.CreateEnterpriseGeodatabase_management(database_platform=database_type,instance_name=instance, database_name=database, account_authentication=account_authentication, database_admin=dbms_admin, database_admin_password=dbms_admin_pwd, sde_schema=schema_type, gdb_admin_name=gdb_admin, gdb_admin_password=gdb_admin_pwd, tablespace_name=tablespace, authorization_file=license)
		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)

环境

此工具不使用任何地理处理环境。

许可信息

  • ArcGIS Desktop Basic: 否
  • ArcGIS Desktop Standard: 是
  • ArcGIS Desktop Advanced: 是

相关主题

  • 在 Oracle 中创建地理数据库
  • 在 Linux 上的 PostgreSQL 中创建地理数据库
  • 在 Windows 上的 PostgreSQL 中创建地理数据库
  • 在 SQL Server 中创建企业级地理数据库
  • “地理数据库管理”工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

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