Create Enterprise Geodatabase (Data Management)

Summary

Creates a database, storage locations, and a database user to act as the geodatabase administrator and owner of the geodatabase. Functionality varies depending on the database management system used. The tool grants the geodatabase administrator the privileges required to create a geodatabase; it then creates a geodatabase in the database.

Usage

  • The following table indicates the tool functionality for each type of database management system:

    FunctionDatabase

    Creates a database

    PostgreSQL and Microsoft SQL Server

    Creates a tablespace

    Oracle

    Creates a geodatabase administrator user in the database

    Oracle, PostgreSQL, and SQL Server

    The tool only creates a user in SQL Server if you create an sde-schema geodatabase.

    Grants the geodatabase administrator the privileges required to create a geodatabase, upgrade a geodatabase, and remove database connections

    Oracle and PostgreSQL

    Grants the geodatabase administrator the privileges required to create a geodatabase and remove database connections

    SQL Server (if creating an sde-schema geodatabase)

    Grants the geodatabase administrator the privileges required to import data using Oracle Data Pump

    Oracle

    Creates a geodatabase in the specified database

    Oracle, PostgreSQL, and SQL Server

  • You must have ArcGIS Desktop (Standard or Advanced), ArcGIS Pro (Standard or Advanced), or ArcGIS Server installed on the computer where you'll create the geodatabase. If you're using Oracle or SQL Server, you must also install and configure a database management system client on the computer where the ArcGIS client is installed.

  • Before you can create a geodatabase in Oracle, you must download the DatabaseSupport.zip (Windows) or DatabaseSupport.tar (Linux) file from My Esri to obtain the st_shapelib (Windows) or libst_shapelib (Linux) library. Place the library on the Oracle server. Be sure to copy the correct library for the operating system where Oracle is installed.

  • You must make a spatial type available to the PostgreSQL database cluster before you create a geodatabase. To use the ST_Geometry type, you must download the DatabaseSupport.zip (Windows) or DatabaseSupport.tar (Linux) file from My Esri to obtain the st_geometry library. Place the library in the %PostgreSQL%\lib directory (Windows) or $PKGLIBDIR directory (Linux) on the PostgreSQL server. Be sure to copy the correct library for the version of PostgreSQL you're using and the operating system where PostgreSQL is installed. To use a PostGIS spatial type, you must install PostGIS in the PostgreSQL database cluster.

  • This tool is not supported with database services.

  • Once the geodatabase is created in PostgreSQL or Oracle, you cannot rename the database in which it is stored. The database name is stored in geodatabase system tables and is used to fully qualify table and feature class names; changing the database name using database tools makes the geodatabase data inaccessible.

  • To generate a license file for an enterprise geodatabases licensed with ArcGIS Enterprise on Kubernetes, use the exportGeodatabaseLicense REST operation.

Parameters

LabelExplanationData Type
Database Platform

Specifies the type of database management system to which a connection to create a geodatabase will be made.

  • OracleConnection to an Oracle instance will be made.
  • PostgreSQLConnection to a PostgreSQL database cluster will be made.
  • SQL Server Connection to a Microsoft SQL Server instance will be made.
String
Instance

The name of the instance.

For SQL Server, provide the SQL Server instance name. Case-sensitive or binary collation SQL Server instances are not supported.

For Oracle, provide either the TNS name or the Oracle Easy Connection string.

For PostgreSQL, provide the name of the server where PostgreSQL is installed.

String
Database
(Optional)

The name of the database.

This parameter is valid for PostgreSQL and SQL Server. You can provide either the name of an existing, preconfigured database or a name for a database that the tool will create.

If the tool creates the database in SQL Server, the file sizes will be either the same as defined for the SQL Server model database or 500 MB for the .mdf file and 125 MB for the .ldf file, whichever is greater. Both the .mdf and .ldf files are created in the default SQL Server location on the database server. Do not name the database sde.

If the tool creates the database in PostgreSQL, it uses the template1 database as the template for the database. If you need to use a different template—for example, you require a template that is enabled for PostGIS—you must create the database before running this tool and provide the name of the existing database. Always use lowercase characters for the database name. If you use uppercase letters, the tool will convert them to lowercase.

String
Operating System Authentication
(Optional)

Specifies the type of authentication that will be used for the database connection.

  • Checked—Operating system authentication will be used. The login information that you provide for the computer where you run the tool is the login that will be used to authenticate the database connection. If the database management system is not configured to allow operating system authentication, authentication will fail.
  • Unchecked—Database authentication will be used. You must provide a valid database username and password for authentication in the database. This is the default. If the database management system is not configured to allow database authentication, authentication will fail.

Boolean
Database Administrator
(Optional)

The database administrator user for database authentication. For Oracle, use the sys user. For PostgreSQL, specify a user with superuser status. For SQL Server, specify any member of the sysadmin fixed server role.

String
Database Administrator Password
(Optional)

The database administrator password for database authentication.

Encrypted String
Sde Owned Schema
(Optional)

This parameter is only active for SQL Server and specifies whether the geodatabase will be created in the schema of the sde user or in the dbo schema in the database. .

  • Checked—The geodatabase will be created in the schema of the sde user.
  • Unchecked—You must be logged in to the SQL Server instance as a user who is dbo in the instance, and the geodatabase will be created in the dbo schema in the database.

Boolean
Geodatabase Administrator
(Optional)

The name of the geodatabase administrator user.

If you are using PostgreSQL, this value must be sde. If the sde login role does not exist, this tool will create it and grant it superuser status in the database cluster. If the sde login role exists, this tool will grant it superuser status if it does not already have it. The tool also creates an sde schema in the database and grants usage on the schema to public.

If you are using Oracle, the value is sde. If the sde user does not exist in the Oracle database, the tool will create it and grant it the privileges required to create and upgrade a geodatabase and disconnect users from the database. The tool also grants privileges to allow data imports using Oracle Data Pump. If the sde user exists, the tool will grant these same privileges to the existing user.

Note:

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

If you are using SQL Server and specified an sde-schema geodatabase, this value must be sde. The tool will create an sde login, database user, and schema and grant it privileges to create a geodatabase and remove connections from the SQL Server instance. If you specified a dbo schema, do not provide a value for this parameter.

String
Geodatabase Administrator Password
(Optional)

The password for the geodatabase administrator user. If the geodatabase administrator user exists in the database management system, the password you provide must match the existing password. If the geodatabase administrator user does not exist, provide a valid database password for the new user. The password must meet the password policy enforced by the database.

The password is an encrypted string.

Encrypted String
Tablespace Name
(Optional)

The name of the tablespace.

This parameter is only valid for Oracle and PostgreSQL database management system types. For Oracle, do one of the following:

  • Provide the name of an existing tablespace. This tablespace will be used as the default tablespace for the geodatabase administrator user.
  • Provide a valid name for a new tablespace. The tool will create a 400 MB tablespace in the Oracle default storage location and set it as the geodatabase administrator's default tablespace.
  • Leave the tablespace blank. The tool will create a 400 MB tablespace named SDE_TBS in the Oracle default storage location. The SDE_TBS tablespace will be set as the geodatabase administrator's default tablespace.

This tool does not create a tablespace in PostgreSQL. You must either provide the name of an existing tablespace to be used as the database's default tablespace or leave this parameter blank. If you leave the parameter blank, the tool will create a database in the pg_default tablespace.

String
Authorization File

The keycodes file that was created when ArcGIS Server was authorized. If you have not done so, authorize ArcGIS Server to create this file.

This file is in the <drive>\Program Files\ESRI\License<release#>\sysgen folder on Windows or the /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen directory on Linux.

Tip:

The /.wine directory is a hidden directory.

You may need to copy the keycodes file from the ArcGIS Server machine to a location that is accessible to the tool.

File
Spatial Type
(Optional)

Specifies the spatial type that will be used. This is only applicable to PostgreSQL databases.

  • ST_GeometryThe ST_Geometry spatial type will be used. This is the default.
  • PostGISThe PostGIS spatial type will be used.
String

Derived Output

LabelExplanationData Type
Create Enterprise Geodatabase Succeeded

Specifies whether the enterprise geodatabase was successfully created.

Boolean

arcpy.management.CreateEnterpriseGeodatabase(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, {spatial_type})
NameExplanationData Type
database_platform

Specifies the type of database management system to which a connection to create a geodatabase will be made.

  • OracleConnection to an Oracle instance will be made.
  • PostgreSQLConnection to a PostgreSQL database cluster will be made.
  • SQL_Server Connection to a Microsoft SQL Server instance will be made.
String
instance_name

The name of the instance.

For SQL Server, provide the SQL Server instance name. Case-sensitive or binary collation SQL Server instances are not supported.

For Oracle, provide either the TNS name or the Oracle Easy Connection string.

For PostgreSQL, provide the name of the server where PostgreSQL is installed.

String
database_name
(Optional)

The name of the database.

This parameter is valid for PostgreSQL and SQL Server. You can provide either the name of an existing, preconfigured database or a name for a database that the tool will create.

If the tool creates the database in SQL Server, the file sizes will be either the same as defined for the SQL Server model database or 500 MB for the .mdf file and 125 MB for the .ldf file, whichever is greater. Both the .mdf and .ldf files are created in the default SQL Server location on the database server. Do not name the database sde.

If the tool creates the database in PostgreSQL, it uses the template1 database as the template for the database. If you need to use a different template—for example, you require a template that is enabled for PostGIS—you must create the database before running this tool and provide the name of the existing database. Always use lowercase characters for the database name. If you use uppercase letters, the tool will convert them to lowercase.

String
account_authentication
(Optional)

Specifies the type of authentication that will be used for the database connection.

  • OPERATING_SYSTEM_AUTHOperating system authentication will be used. The login information that you provide for the computer where you run the tool is the login that will be used to authenticate the database connection. If the database management system is not configured to allow operating system authentication, authentication will fail.
  • DATABASE_AUTHDatabase authentication will be used. You must provide a valid database username and password for authentication in the database. This is the default. If the database management system is not configured to allow database authentication, authentication will fail.
Boolean
database_admin
(Optional)

The database administrator user for database authentication. For Oracle, use the sys user. For PostgreSQL, specify a user with superuser status. For SQL Server, specify any member of the sysadmin fixed server role.

String
database_admin_password
(Optional)

The database administrator password for database authentication.

Encrypted String
sde_schema
(Optional)

This parameter is only relevant to SQL Server and specifies whether the geodatabase will be created in the schema of a user named sde or in the dbo schema in the database. If creating a dbo-schema geodatabase, connect as a user who is dbo in the SQL Server instance.

  • SDE_SCHEMAThe geodatabase repository is owned by and will be stored in the schema of a user named sde. This is the default.
  • DBO_SCHEMAThe geodatabase repository will be stored in the dbo schema in the database.
Boolean
gdb_admin_name
(Optional)

The name of the geodatabase administrator user.

If you are using PostgreSQL, this value must be sde. If the sde login role does not exist, this tool will create it and grant it superuser status in the database cluster. If the sde login role exists, this tool will grant it superuser status if it does not already have it. The tool also creates an sde schema in the database and grants usage on the schema to public.

If you are using Oracle, the value is sde. If the sde user does not exist in the Oracle database, the tool will create it and grant it the privileges required to create and upgrade a geodatabase and disconnect users from the database. The tool also grants privileges to allow data imports using Oracle Data Pump. If the sde user exists, the tool will grant these same privileges to the existing user.

Note:

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

If you are using SQL Server and specified an sde-schema geodatabase, this value must be sde. The tool will create an sde login, database user, and schema and grant it privileges to create a geodatabase and remove connections from the SQL Server instance. If you specified a dbo schema, do not provide a value for this parameter.

String
gdb_admin_password
(Optional)

The password for the geodatabase administrator user. If the geodatabase administrator user exists in the database management system, the password you provide must match the existing password. If the geodatabase administrator user does not exist, provide a valid database password for the new user. The password must meet the password policy enforced by the database.

The password is an encrypted string.

Encrypted String
tablespace_name
(Optional)

The name of the tablespace.

This parameter is only valid for Oracle and PostgreSQL database management system types. For Oracle, do one of the following:

  • Provide the name of an existing tablespace. This tablespace will be used as the default tablespace for the geodatabase administrator user.
  • Provide a valid name for a new tablespace. The tool will create a 400 MB tablespace in the Oracle default storage location and set it as the geodatabase administrator's default tablespace.
  • Leave the tablespace blank. The tool will create a 400 MB tablespace named SDE_TBS in the Oracle default storage location. The SDE_TBS tablespace will be set as the geodatabase administrator's default tablespace.

This tool does not create a tablespace in PostgreSQL. You must either provide the name of an existing tablespace to be used as the database's default tablespace or leave this parameter blank. If you leave the parameter blank, the tool will create a database in the pg_default tablespace.

String
authorization_file

The keycodes file that was created when ArcGIS Server was authorized. If you have not done so, authorize ArcGIS Server to create this file.

This file is in the <drive>\Program Files\ESRI\License<release#>\sysgen folder on Windows or the /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen directory on Linux.

Tip:

The /.wine directory is a hidden directory.

You may need to copy the keycodes file from the ArcGIS Server machine to a location that is accessible to the tool.

File
spatial_type
(Optional)

Specifies the spatial type that will be used. This is only applicable to PostgreSQL databases.

  • ST_GEOMETRYThe ST_Geometry spatial type will be used. This is the default.
  • POSTGISThe PostGIS spatial type will be used.
String

Derived Output

NameExplanationData Type
out_result

Specifies whether the enterprise geodatabase was successfully created.

Boolean

Code sample

CreateEnterpriseGeodatabase example 1 (Python window)

The following script creates a geodatabase in an Oracle database.

It creates an sde user and a default tablespace, sdetbs, for the sde user.

The keycodes file is on a remote Linux server.


import arcpy
arcpy.management.CreateEnterpriseGeodatabase(
    "ORACLE", "ora11g:1521/elf", "", "DATABASE_AUTH", "sys", 
    "manager", "", "sde", "supersecret", "sdetbs", 
    "//myserver/mymounteddrive/myaccessibledirectory/keycodes")
CreateEnterpriseGeodatabase example 2 (Python window)

This script connects to a SQL Server instance, (tor\ssinstance), to create a database named sp_data and an sde-schema geodatabase in it.

The connection is made using operating system authentication. The keycodes file is on a remote Windows server.


import arcpy
arcpy.management.CreateEnterpriseGeodatabase(
    "SQL_SERVER", "tor\ssinstance1", "sp_data", "OPERATING_SYSTEM_AUTH", "", "", 
    "SDE_SCHEMA", "sde", "sde", "", "//myserver/myaccessibledirectory/keycodes")
CreateEnterpriseGeodatabase example 3 (Python window)

This script connects to a PostgreSQL database cluster on a server named feldspar.

An sde user is created as is a database, pggdb, in the existing tablespace, gdbspace.

The keycodes file is on the local Linux server.

The geodatabase will use the ST_Geometry spatial type.


import arcpy
arcpy.management.CreateEnterpriseGeodatabase(
    "POSTGRESQL", "feldspar", "pggdb", "DATABASE_AUTH", "postgres", "averturis", 
    "", "sde", "nomira", "gdbspace", 
    "//arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License/sysgen/keycodes" "ST_GEOMETRY")
CreateEnterpriseGeodatabase example 4 (stand-alone script)

The following stand-alone Python script allows you to provide information specific to your site using options.

"""
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)

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics