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
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 其他...

向 Oracle 添加用户

  • 添加可创建数据库对象的用户
  • 使用 Oracle 工具创建用户

Oracle 数据库管理员在 Oracle 实例中创建用户帐户并为这些帐户分配存储(表空间)和权限。

数据库管理员(系统用户)可使用 Oracle 工具创建用户,为用户分配默认表空间,并向用户授予创建数据库对象的权限。此外,数据库管理员还可使用创建数据库用户工具或 ArcGIS 客户端的脚本来创建数据所有者用户。将向使用此工具创建的用户授予以下权限:

  • CREATE SESSION
  • CREATE SEQUENCE
  • CREATE TABLE
  • CREATE TRIGGER
  • CREATE VIEW
  • SELECT ON DBA_ROLES

添加可创建数据库对象的用户

您可以运行 ArcGIS for Desktop 中的创建数据库用户工具或调用 Python 脚本工具来创建数据库用户,该用户可创建表、要素类、视图、触发器和序列。

要运行创建数据库用户工具,您必须以 Oracle 系统用户的身份连接到数据库。

使用创建数据库用户工具

  1. 启动 ArcMap 或 ArcCatalog。
  2. 以系统用户的身份连接到数据库或地理数据库。
  3. 打开创建数据库用户工具。

    该工具位于“数据管理”工具箱的“地理数据库管理”工具集中。

  4. 指定输入数据库连接的数据库连接。
  5. 为工具将要创建的用户和方案输入名称。
  6. 为数据库用户输入密码。
  7. 如果您已具有组角色并希望此用户成为该组的成员,请指定该用户的角色。
  8. 输入用作用户默认表空间的表空间名称。如果表空间不存在,则此工具将在 Oracle 默认存储位置创建表空间。工具将创建 400 MB 的表空间。

    如果不指定表空间,则使用 Oracle 默认表空间。

  9. 单击确定以运行工具。

运行 Python 脚本

如果为用户创建编写脚本,请按照以下步骤操作:

  1. 在 ArcGIS 客户端计算机上创建文本文件,然后将以下脚本复制到此文件。

    """
    Name: create_database_user.py
    Description: Provide connection information to a database user.
    Type create_database_user.py -h or create_database_user.py --help for usage
    Author: Esri
    """
    
    # 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 10.1 release")
    
    #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:  Not required 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 ("--utype", dest="user_type", type ="choice", choices=['DATABASE_USER', 'OPERATING_SYSTEM_USER'], default='DATABASE_USER', help="Authentication type options (case-sensitive):  DATABASE_USER, OPERATING_SYSTEM_USER.  Default=DATABASE_USER")
    parser.add_option ("-u", dest="dbuser", type="string", default="", help="database user name")
    parser.add_option ("-p", dest="dbuser_pwd", type="string", default="", help="database user password")
    parser.add_option ("-r", dest="role", type="string", default="", help="role to be granted to the user")
    parser.add_option ("-t", dest="Tablespace", type="string", default="", help="Tablespace name")
    # 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
    	dbuser = options.dbuser
    	dbuser_pwd = options.dbuser_pwd	
    	tablespace = options.Tablespace
    	user_type = options.user_type
    	role = options.role
    
    	
    	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(database_type == "SQL_SERVER"):
    		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( dbuser.lower() == ""):
    			print("\n%s: error: %s\n" % (sys.argv[0], "Database user must be specified."))
    			sys.exit(3)		
    		if( dbms_admin == ""):
    			print("\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified!"))
    			sys.exit(3)
    
    	if ( user_type == "DATABASE_USER" and (dbuser =="" or dbuser_pwd =="")):
    		print(" \n%s: error: \n%s\n" % (sys.argv[0], "To create database authenticated user, user name and password must be specified!"))
    		parser.print_help()
    		sys.exit(3)	
    
    	# 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 a user in an enterprise geodatabase or database requires an ArcGIS for Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS for Server license.")
    		sys.exit("Re-authorize ArcGIS before creating a database user.")
    	else:
    		print("\n" + product_license + " license available!  Continuing to create...")
    		arcpy.AddMessage("+++++++++")
    
    	# Local variables
    	instance_temp = instance.replace("\\","_")
    	instance_temp = instance_temp.replace("/","_")
    	instance_temp = instance_temp.replace(":","_")
    	Conn_File_NameT = instance_temp + "_" + database + "_" + dbms_admin   
    
    	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)
    
    	try:
    		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(temp , Connection_File_Name, database_type, instance, database, account_authentication, dbms_admin, dbms_admin_pwd, "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=dbms_admin, password=dbms_admin_pwd, 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")
    
    		print("Creating database user...\n")
    		arcpy.CreateDatabaseUser_management(input_workspace=Connection_File_Name_full_path, user_authentication_type=user_type, user_name=dbuser, user_password=dbuser_pwd, role=role, tablespace_name=tablespace)
    		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)
    

    您可以在安装了具有 Geodatabase Update 扩展模块的 ArcGIS for Desktop(Standard 或 Advanced)、ArcGIS for Server(Standard 或 Advanced)或 ArcGIS Engine 的计算机上运行脚本。

  2. 以 .py 扩展名保存该文件。
  3. 运行脚本,同时提供 Oracle 数据库特定的选项和信息以及要创建的用户。

    在下列通过 Windows 服务器运行脚本的示例中,脚本名称为 create_database_user.py。使用 Oracle 连接字符串 dbsrv/orcl 在数据库中创建经数据库验证的用户(地理数据)。未将此用户添加到角色。

    create_database_user.py --DBMS ORACLE -i dbsrv/orcl -U sys -P $hHhH --utype DATABASE_USER -u geodata -p 0wn1t
    

    这是在 Linux 计算机上运行脚本的示例:

    ./create_database_user.py --DBMS ORACLE -i dbsrv/orcl -U sys -P $hHhH --utype DATABASE_USER -u geodata -p 0wn1t
    

    提示:

    在命令提示符处输入 -h 或 --help 来获取语法帮助。

此时,数据库已具有可创建表的用户。

此用户可在数据库或地理数据库中以多种方式创建表。有关使用 ArcGIS 创建表的信息,请参阅将数据集添加到地理数据库的概述。

如果已存在数据集,所有者可向需要查看数据的用户授予数据集的 SELECT 权限,并向需要编辑数据的用户授予数据集的 SELECT、INSERT、UPDATE 和 DELETE 权限。有关说明,请参阅授予和撤消数据集权限。

使用 Oracle 工具创建用户

如果需要创建的用户的权限不同于由创建数据库用户工具所授予的权限,或不具有直接授予的任何权限,可以使用 Oracle 工具创建用户。创建用于 ArcGIS 的自有帐户时,请牢记以下注意事项:

  • Oracle 中的地理数据库使用共享日志文件表来维护所选记录的列表。此类日志文件要求所有用户都具有创建表的权限。如果要创建无法在地理数据库中创建表的用户,则您必须将日志文件表的设置更改为使用 sde 用户所有的日志文件表池。有关日志文件池的描述,请参阅有关 Oracle 地理数据库中的日志文件表选项。要更改日志文件表的设置,请按照更改日志文件表设置中的说明进行操作。
  • 如果选择将 OS 身份验证应用到 Oracle 数据库,则需要在 Oracle 实例中对用户帐户和 Oracle 配置文件进行特定的设置才能使用 OS 身份验证。有关您的数据库版本所需的具体设置步骤,请参阅 Oracle 文档。

有关使用 Oracle 工具创建数据库用户的说明,请参阅 Oracle 文档。

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

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