Create a geodatabase in Oracle

Available with Standard or Advanced license.

To create a geodatabase in an Oracle database, run a geoprocessing tool or Python script from an ArcGIS client.

When you create a geodatabase from ArcGIS Pro 3.2, the geodatabase version is 11.2.0.

Start by reading the prerequisites, and follow the instructions that apply to your situation.

Note:

Creating or upgrading user-schema geodatabases in Oracle is no longer supported.

Prerequisites

To create a geodatabase in Oracle, do the following:

  1. Confirm that the ArcGIS, Oracle, and operating system combinations you want to use are compatible.
  2. Obtain the Oracle client required to connect to the version of Oracle you'll use to store your geodatabase.
  3. Obtain an ArcGIS Server keycodes file—which is created when you authorize ArcGIS Server—and place it in a location you can access from the ArcGIS client you'll use to create the geodatabase.
  4. Determine who will create the geodatabase, as that affects which tool you run to create the geodatabase. Follow the instructions that apply to your situation:

You are the database and geodatabase administrator

If you perform the role of both the database administrator and geodatabase administrator and, therefore, know the password for both logins, you can use the Create Enterprise Geodatabase geoprocessing tool, or a Python script that calls this tool, to create a geodatabase in Oracle.

The Create Enterprise Geodatabase tool creates the sde user, schema, and tablespace, and grants privileges to the sde user that are required to create the geodatabase. To achieve this, the tool uses the following default settings:

  • Creates a database user named sde
  • Creates a 400 MB tablespace in the Oracle default location and sets it as the sde user's tablespace
  • Grants the sde user privileges to create and upgrade a geodatabase, remove database connections, and import data using Oracle Data Pump
  • Grants package privileges required to create a geodatabase
  • Creates a geodatabase

For more information on required privileges, see Privileges for geodatabases in Oracle.

Note:

You cannot use this workflow to create a geodatabase in a database service.

Before you run the tool or script to create a geodatabase, you must set up Oracle.

Install and configure Oracle

Before you create a geodatabase, Oracle must be installed and configured. How you (or your IT department) configure the Oracle instance depends on the specific needs of your organization. Consult the Oracle documentation for installation and configuration information.

Check the ArcGIS system requirements for Oracle before you create a geodatabase to be sure the Oracle, ArcGIS, and hardware combinations you want to use are supported.

If you require the ability to do any of the following, you also need to configure the Oracle extproc to access the Esri ST_Geometry libraries:

After Oracle is installed and configured, install ArcGIS and Oracle clients.

Install and configure clients

You can install ArcGIS Pro (Desktop Standard or Desktop Advanced) or ArcGIS Server (enterprise edition) and run a script to create a geodatabase. To run the Create Enterprise Geodatabase geoprocessing tool instead of a script, install ArcGIS Pro.

Note:

You need an ArcGIS Server (enterprise) keycodes file to authorize your geodatabase in the next section. Even if you do not run a Python script from an ArcGIS Server machine to create the geodatabase, you must install and authorize ArcGIS Server to get the keycodes file. You may need to copy the file from the ArcGIS Server machine to a location the geoprocessing tool or Python script can access.

In most cases, your ArcGIS client will be installed on a different computer than Oracle. Therefore, you must have a supported Oracle client on the ArcGIS client computer to connect to the Oracle instance. See the Oracle documentation to determine which version of the Oracle client you must install to connect to the version of Oracle you are using and for instructions to install and configure the Oracle client.

  1. Install the ArcGIS client you'll use to create the geodatabase.

    Follow the instructions provided in the software installation guides.

  2. Install and configure an Oracle client on the ArcGIS client computer.

    You can obtain the Oracle Instant, Runtime, or Administrator Client from Oracle. See the Oracle documentation for instructions to install.

  3. Set the environment variable of your operating system or user profile to include the path to and name of the directory where the Oracle client is installed.

    • On Linux, set the LD_LIBRARY_PATH environment variable.
    • On Microsoft Windows, set the PATH environment variable.

  4. If the ArcGIS client was already running, restart it to recognize the Oracle client and new environment variables.
  5. You can connect from ArcGIS to Oracle using an Easy Connect string, but you must configure your Oracle database to allow Easy Connect strings.

    If you have the full Oracle client installed but want to use Easy Connect syntax to connect, be sure the sqlnet.ora file on the client is configured to allow the use of Easy Connect and the Oracle server is configured to allow Easy Connect syntax. See the Oracle documentation for further instructions.

Now you can create a geodatabase.

Create a geodatabase

You can run the Create Enterprise Geodatabase tool from ArcGIS Pro (Desktop Standard or Desktop Advanced), or run a Python script from ArcGIS Pro or an ArcGIS Server machine to create an sde user, schema, tablespace, and geodatabase.

Run the Create Enterprise Geodatabase tool

You can run a geoprocessing tool to create the geodatabase in ArcGIS Pro.

Follow these steps to create a geodatabase using the Create Enterprise Geodatabase tool:

  1. Start ArcGIS Pro.
  2. Open the Create Enterprise Geodatabase tool.

    You can search for or browse to this tool, which is located in the Geodatabase Administration toolset of the Data Management toolbox.

  3. Choose Oracle from the Database Platform drop-down list.
  4. Provide the information required to connect to the Oracle instance.
    • If you already configured the Oracle client to use a TNS network alias, type the Net service alias in the Instance text box.
    • If you have not configured the Oracle client's network alias and your Oracle database and client are configured to use Easy Connect strings, provide the Oracle Easy Connect string in the Instance text box.

    See Connect to Oracle from ArcGIS for a list of possible Easy Connect strings.

  5. The Database Administrator text box is populated with the sys username because you must connect to the database as a database administrator to create the geodatabase administrator and tablespace.
  6. Type the sys user's password in the Database Administrator Password text box.
  7. Type sde in the Geodatabase Administrator text box.

    If the sde user does not exist in the database, the tool creates it and grants it the privileges necessary to create a geodatabase. If the user exists, the required privileges are granted to it.

  8. Type a password for the sde user in the Geodatabase Administrator Password text box.

    If the sde user already exists in the database, you must type the correct password for the existing user; this tool will not change the password. If you are creating an sde user, the password you type is used when creating the sde user.

  9. Specify a tablespace for the sde user.
    • If you have a preconfigured tablespace to be used for the geodatabase repository, type its name in the Tablespace Name text box.
    • To create a tablespace, type a valid name in the Tablespace Name text box and the tool creates a 400 MB tablespace in the Oracle default location. If you do not type a tablespace name, SDE_TBS tablespace is created and set as the default tablespace for the sde user.
  10. To specify an Authorization File, browse to and choose the keycodes file that was created when you authorized ArcGIS Server.

    If you have not already done so, authorize ArcGIS Server now to create the keycodes file. This file is written to the \\Program Files\ESRI\License<release#>\sysgen folder on Windows servers and /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen on Linux servers. Copy the keycodes file to a location the tool can access.

  11. Click Run.

A geodatabase is created in the Oracle database.

Messages about geodatabase creation are written to the sde_setup.log file, which is created in the directory specified for your %TEMP% variable on the computer where the tool is run. If you have any problems creating a geodatabase, review this log file to troubleshoot the problem.

Next, if the Oracle database open_cursors parameter is set to anything other than 300, run the sde.gdb_util.update_open_cursors stored procedure to synchronize your Oracle database parameter with the geodatabase's setting.

Run a Python script

You can copy, save, and run the script provided here to create a geodatabase from ArcGIS Pro (Desktop Standard or Desktop Advanced) or an ArcGIS Server machine.

  1. Create a text file on the ArcGIS client machine and copy the following script into the file:
    """
    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
    Author: Esri
    """
    
    # Import system modules
    import arcpy, os, optparse, sys
    
    
    # Define usage and version
    parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0 for 10.1 and higher releases")
    
    #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 ("--schema", dest="Schema_type", type="choice", choices=['SDE_SCHEMA', 'DBO_SCHEMA'], default="SDE_SCHEMA", help="Schema Type for SQL Server geodatabase, SDE or DBO. Default=SDE_SCHEMA")
    parser.add_option ("-u", dest="Gdb_admin", type="string", default="", help="Geodatabase administrator user name")
    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")
    parser.add_option ("-l", dest="Authorization_file", type="string", default="", help="Full path and name of authorization file")
    parser.add_option ("--type", dest="Spatial_type", type="choice", choices=['ST_GEOMETRY', 'POSTGIS'], default="ST_GEOMETRY", help="Spatial Type for PostgreSQL geodatabase, ST_GEOMETRY or POSTGIS. Default=ST_GEOMETRY")
    
    # 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
    	spatial_type = options.Spatial_type.upper()
    	
    	
    	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( 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 for Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS for 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.management.CreateEnterpriseGeodatabase(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, spatial_type=spatial_type)
    		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)
  2. Save the file with a .py extension.
  3. Run the script, providing options and information specific to your site.

    In the following example run from a Linux machine, the file create_gdb.py is run for an Oracle instance with an SID of orcl. The instance is running on server gisprod. An sde user with password Tgdbst@rtsh3r3 is created, along with a tablespace named sde. A keycodes file in the default ArcGIS Server location is specified to authorize the geodatabase.

    ./create_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH -U sys
     -P N0pe3king! -u sde -p Tgdbst@rtsh3r3 -t sde -l '/usr/arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License/sysgen/keycodes'

    In this example, the same script is run from a Windows machine:

    create_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH -U sys
     -P N0pe3king! -u sde -p Tgdbst@rtsh3r3 -t sde -l '\\Program Files\ESRI\License\sysgen\keycodes'
    Tip:

    Type -h or --help at the command prompt to get syntax help.

You now have a geodatabase in Oracle.

Messages about geodatabase creation are written to the sde_setup.log file, which is created in the directory specified for your TEMP or TMP variable on the computer where the tool is run. If you have any problems creating a geodatabase, review this log file to troubleshoot the problem.

Next, if the Oracle database open_cursors parameter is set to anything other than 300, run the sde.gdb_util.update_open_cursors stored procedure to synchronize your Oracle database parameter with the geodatabase's setting.

The Oracle administrator configures the database; the geodatabase administrator creates the geodatabase

If the person creating the geodatabase does not have access to the database administrator's password, the database administrator can set up the database and sde user, and then the geodatabase administrator can connect to the database using the sde login and create a geodatabase using the Enable Enterprise Geodatabase geoprocessing tool or a Python script.

The Enable Enterprise Geodatabase tool takes a database connection file as input and creates the geodatabase system tables, views, functions, and procedures in the sde user's schema.

Install and configure Oracle

Before the geodatabase administrator can create a geodatabase, the database administrator must do the following:

  • Install and configure an Oracle instance. How you configure the Oracle instance depends on the specific needs of your organization. Consult Oracle documentation for installation and configuration information.

    Check the ArcGIS system requirements to ensure the database management system, ArcGIS, and hardware combinations you want to use are supported.

  • Create an sde user and schema.
  • Grant the sde user the privileges necessary to create a geodatabase. See Privileges for geodatabases in Oracle for a list of required privileges.
  • Create a tablespace for the sde user and set the tablespace as the sde user's default tablespace.
  • Grant execute privileges on packages needed for geodatabase creation. See Privileges for geodatabases in Oracle for a list of the packages.

If you require the ability to do any of the following, you must also configure the Oracle extproc to access the Esri ST_Geometry libraries:

After Oracle is installed and configured, the geodatabase administrator can install ArcGIS and Oracle clients.

Install and configure clients

You can install ArcGIS Pro (Desktop Standard or Desktop Advanced) or ArcGIS Server to run a Python script and create a geodatabase. If you want to run the Enable Enterprise Geodatabase geoprocessing tool instead of a script, install ArcGIS Pro.

Note:

You need an ArcGIS Server (enterprise) keycodes file to authorize your geodatabase in the next section. Even if you do not run a Python script from an ArcGIS Server machine to create the geodatabase, you must install and authorize ArcGIS Server to get the keycodes file. You may need to copy the file from the ArcGIS Server machine to a location the geoprocessing tool or Python script can access.

In most cases, your ArcGIS client will be installed on a different computer than Oracle. Therefore, you must have a supported Oracle client on the ArcGIS client computer to connect to the Oracle instance. See Oracle documentation to determine which version of the Oracle client you should install to connect to the version of Oracle you are using and for instructions on installing and configuring the client.

  1. Install the ArcGIS client you'll use to create the geodatabase.

    Follow the instructions provided in the software installation guides.

  2. Install and configure an Oracle client on the ArcGIS client computer.

    You can obtain the Oracle Instant, Runtime, or Administrator Client from Oracle. See the Oracle documentation for instructions to install.

  3. Set the environment variable of your operating system or user profile to include the path to and name of the directory where the Oracle client is installed.

    • On Linux, set the LD_LIBRARY_PATH environment variable.
    • On Windows, set the PATH environment variable.

  4. If the ArcGIS client was already running, restart it to recognize the Oracle client and new environment variables.
  5. You can connect from ArcGIS to Oracle using an Easy Connect string. However, the database administrator must configure the Oracle database to allow Easy Connect strings. If you have the full Oracle client installed but want to use Easy Connect syntax to connect, ensure the sqlnet.ora file on the client is configured to allow the use of Easy Connect and that the database administrator has configured the Oracle server to allow Easy Connect syntax. See the Oracle documentation for further instructions.

Now you can create a geodatabase.

Create a geodatabase

The geodatabase administrator can run the Enable Enterprise Geodatabase tool from ArcGIS Pro (Desktop Standard or Desktop Advanced), or run a Python script from an ArcGIS Pro (Desktop Standard or Desktop Advanced) or ArcGIS Server machine to create a geodatabase in the existing database.

Run the Enable Enterprise Geodatabase ArcGIS Desktop tool

Run the geoprocessing tool from ArcGIS Pro to create a geodatabase.

Follow these steps to create a geodatabase using the Enable Enterprise Geodatabase geoprocessing tool:

  1. Start ArcGIS Pro.
  2. Connect to the Oracle database as the sde user.

    Save the user's password on the Database Connection dialog box.

  3. Open the Enable Enterprise Geodatabase geoprocessing tool.
  4. Use the database connection you created in step 2 for Input Database Connection.
  5. Browse to the authorization file that was created when you authorized ArcGIS Server and add it to the Authorization File text box.

    If you have not already done so, authorize ArcGIS Server to create this file. When you use the wizard to authorize ArcGIS Server, a keycodes file is written to the server where the software is installed. If you authorized ArcGIS Server on a Linux machine, the keycodes file was created in /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release>/sysgen. If you authorized on a Windows server, the file was created in Program Files\ESRI\License<release>\sysgen. Copy the keycodes file to a location the tool can access.

  6. Click Run.

A geodatabase is created in the database.

Messages about geodatabase creation are written to the sde_setup.log file, which is created in the directory specified for your %TEMP% variable on the computer where the tool is run. If you have any problems creating a geodatabase, review this log file to troubleshoot the problem.

If clients will access the geodatabase using SQL, configure the Oracle extproc to allow access.

Next, the database administrator can synchronize open_cursors settings between Oracle and the geodatabase using the sde.gdb_util.update_open_cursors stored procedure.

Run a Python script

If you want to create the geodatabase by running a script from an ArcGIS Server or ArcGIS Pro installation, you can use the script provided here.

  1. Create a text file on the ArcGIS client machine and copy the following script into the file:

    """
    Name: enable_enterprise_gdb.py
    Description: Provide connection information to an enterprise database
    and enable enterprise geodatabase.
    Type enable_enterprise_gdb.py -h or enable_enterprise_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 for " + arcpy.GetInstallInfo()['Version'] )
    
    #Define help and options
    parser.add_option ("--DBMS", dest="Database_type", type="choice", choices=['SQL_SERVER', 'ORACLE', 'POSTGRESQL', 'DB2','INFORMIX','DB2ZOS', ''], default="", help="Type of enterprise DBMS:  SQL_SERVER, ORACLE, POSTGRESQL, DB2, INFORMIX, or DB2ZOS.")
    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 ("-D", dest="Database", type="string", default="none", help="Database name:  Not required for Oracle")
    parser.add_option ("-l", dest="Authorization_file", type="string", default="", help="Full path and name of authorization file")
    
    
    # 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
    	account_authentication = options.account_authentication.upper()
    	username = options.User.lower() 
    	password = options.Password	
    	database = options.Database.lower()
    	license = options.Authorization_file
    
    
    	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)
    
    		
    	# Get the current product license
    	product_license=arcpy.ProductInfo()
    	
    	if (license == ""):
    		print(" \n%s: error: %s\n" % (sys.argv[0], "Authorization file (-l) must be specified."))
    		parser.print_help()
    		sys.exit(3)
    	
    	# Checks required license level
    	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
    		print("\n" + product_license + " license found!" + "  Enabling enterprise geodatabase functionality requires an ArcGIS Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS Server license.")
    		sys.exit("Re-authorize ArcGIS before enabling an enterprise geodatabase.")
    	else:
    		print("\n" + product_license + " license available!  Continuing to enable...")
    		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")
    	
    	# Process: Enable geodatabase...
    	try:
    		print("Enabling Enterprise Geodatabase...\n")
    		arcpy.EnableEnterpriseGeodatabase_management(input_database=Connection_File_Name_full_path, 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)
    			
    	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)

  2. Save the file with a .py extension.
  3. Run the script, providing options and information specific to your site.

    In the following example run from a Linux machine, the file enable_gdb.py is run for an Oracle instance with an SID of orcl. The instance is running on server gisprod. A keycodes file in the default ArcGIS Server location is specified to authorize the geodatabase.

    enable_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH 
    -u sde -p Tgdbst@rtsh3r3 -l '/usr/arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License/sysgen/keycodes'

    In this example, the same script is run from a Windows machine:

    create_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH -U sys
     -P N0pe3king! -u sde -p Tgdbst@rtsh3r3 -t sde -l '\\Program Files\ESRI\License\sysgen\keycodes'
    Tip:

    Type -h or --help at the command prompt to get syntax help.

You now have a geodatabase in the Oracle database.

Messages about geodatabase creation are written to the sde_setup.log file, which is created in the directory specified for your TEMP or TMP variable on the computer where the script is run. If you have any problems creating a geodatabase, review this log file to troubleshoot the problem.

Next, the database administrator can synchronize open_cursors settings between Oracle and the geodatabase using the sde.gdb_util.update_open_cursors stored procedure.