Select to view content in your preferred language

How to rename default version to "Default" ?

4774
10
03-19-2012 12:03 PM
JeanManchseck
Emerging Contributor
Hi all,

We are facing a problem due to a mistake of a, now, ex SDE admin : the renaming of the "DEFAULT"  version of our SDE connection which leads to the unability to connect anymore to the default mother version of our database with admin rights to restore to the previous state.

We get the "failed to connect to database. Version not found  [sde.DEFAULT]" popup as we try to check the properties and "failed to connect to the specified server. Version not found  [dbo.DEFAULT]. Version not found  [sde.DEFAULT]. Version not found  [sde.DEFAULT]. Version not found  [sde.DEFAULT]" when we try to change the transactional version in order to point to the renamed default version.

Following the documentation it seems that the mother version can't normally be renamed but unlucky it may be ...
It's very odd not to have a warning or any lock on the renaming of a mother version though. Anyway it's not the time to complain about it but to get the trick in order to rename to "DEFAULT" our mother version. Any help will be appreciated !

Thanks all, have a nice day,
Jean
0 Kudos
10 Replies
JakeSkinner
Esri Esteemed Contributor
Before proceeding I would recommend to create a database backup.  Then, try executing the following query:

for SQL Server
update sde.sde_versions set name = 'DEFAULT' where version_id = 1


or if you're running Oracle
update sde.versions set name = 'DEFAULT' where version_id = 1


Afterwards, try making a connection to the SDE geodatabase.
0 Kudos
JeanManchseck
Emerging Contributor
Hi JSkinn3,

Thanks a lot for the quick answer !

We are running postgresql database, so would you be kind to give us the query for it ? Sorry, I forgot to mention it in the first post.

Jean
0 Kudos
KimPeter
Esri Contributor
The query for PostgreSQL should be the same as for SQL Server, since the system table name is the same in both: sde_versions.

update sde.sde_versions set name = 'DEFAULT' where version_id = 1
0 Kudos
JeanManchseck
Emerging Contributor
Thanks a lot JSkinn3 and kpeter for helping us, everything is back to default state and we're now able to connect to our data ! 😉
Your query is already written in the how to's list.

Have a very nice day,
Jean
0 Kudos
VasiliiSelivanov
Emerging Contributor
Hi. Can you help me?
I've created an Enterprise Geodatabase with python script and now I am trying to connect to this database
in ArcCatalog 10.1 but it's keep to alert message: Failed to connect to database. Version not found [DBO.DEFAULT].
How can I connect to this database? I'm appreciate any help!
0 Kudos
JakeSkinner
Esri Esteemed Contributor
When you created the Enterprise Geodatabase, did you create it with an SDE owned schema? 

Can you post the python script you used to create the Enterprise Geodatabase?
0 Kudos
VasiliiSelivanov
Emerging Contributor
Thanks for fast response=)
This is the python script to create a geodatabase:
"""
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 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 ("--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")
# 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"
    sys.exit(3)
   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 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("+++++++++")
        license = "C:\Program Files\ESRI\License10.1\sysgen\keycodes"
        print "authorization_file " + license + "\n" 
 
 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)


This is that i wrote to execute that script in cmd.exe with output:
C:\Python27\ArcGISx6410.1>python createArcgisDatabase.py --DBMS=SQLSERVER -i ROM
ANPC\ARCGISSQLSERVER -D kostroma -U sa -P 112 -u sde -p 112 -l "C:\Program Files
\ESRI\License10.1\sysgen\keycodes"

ArcServer license available!  Continuing to create...
+++++++++
authorization_file C:\Program Files\ESRI\License10.1\sysgen\keycodes

Creating enterprise geodatabase...

Executing: CreateEnterpriseGeodatabase SQL_Server ROMANPC\ARCGISSQLSERVER kostro
ma DATABASE_AUTH sa ***** SDE_SCHEMA sde ***** # "C:\Program Files\ESRI\License1
0.1\sysgen\keycodes"
Start Time: Tue Sep 11 12:19:03 2012
User has privileges required to create database objects.
Database created.
Geodatabase admin user created.
Validated authorization file.
User has required privileges for geodatabase setup.
XML support is enabled for the database instance.
Created geodatabase tables and stored procedures.
Finished creating geodatabase schema.
Succeeded at Tue Sep 11 12:19:34 2012 (Elapsed Time: 31,00 seconds)
+++++++++



Everything was created but I've just was unable to connect this database.
And i changed owner from 'sde' to 'dbo' :
update sde.sde_versions set owner = 'dbo' where version_id = 1.

Now I can connect to database but I don't know is it right solution?

PS: And if do you know how to create feature service in order to edit polygons on the map,
can you provide me with some help links to manage it?
I really appreciate it=)
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Vasilii,

I was able to get your script to execute successfully and was able to connect without error.  I would not recommend using your workaround of renaming the Default version owner to DBO.  This will not change who owns all the geodatabase metadata, and this could potentially cause problems down the road.

The previously offered solution to change the version name was due to the former SDE admin originally altering the name.

I would try deleting the geodatabase and re-executing your script.  Or, simply run the 'Create Enterprise Geodatabase' tool from ArcToolbox.
0 Kudos
SalmanSiddiqui
New Contributor

Hi Jake or Kim, 

Can you please help me with my problem? I have created an Enterprise Geodatabase but forget to tick the Sde Owned Schema and it resulted in a dbo owned database. Is it possible to convert or change the owner to sde i.e sde.default ?

0 Kudos