Error: Underlying DBMS error[Microsoft OLE DB Provider for SQL Server: Violation of UNIQUE KEY constraint 'GDB_OC_UC'
When creating a new feature class or table in an ArcSDE geodatabase, the following error message may occur:
"Failed to create feature class.Underlying DBMS error[Microsoft OLE DB Provider for SQL Server:Violation of UNIQUE KEY constraint 'GDB_OC_UC'. Cannot insert duplicate key in object'GDB_OBJECTCLASSES'.]"
The error occurs under the following circumstances:
1. A table or feature class previously existed in the user's schema that had the same name as the one to be created and was stored in the same database.
2. The original table or feature class was created using ArcGIS Desktop.
3. The original table or feature class was deleted using the ArcSDE Administrator commands
Code: SDELAYER -o delete
Code: SDETABLE -o delete
When a table or feature class is created by way of ArcGIS Desktop, a row for that object is created in the GDB_OBJECTCLASSES table. This table exists in the ArcSDE metadata repository and is owned by the SDE user. There is a unique constraint on this table that prevents the creation of objects in the same database that have the same name and owner.
The ArcSDE administrator commands were created prior to the implementation of the geodatabase in ArcSDE, and thus do not manage or have knowledge of the GDB_* tables in the ArcSDE metadata repository. Therefore, if an object is deleted that has an entry in any of the GDB_* tables by way of the Administrator commands, those entries are not deleted.
To prevent this situation from occuring, use ArcCatalog to delete any objects in ArcSDE that were created by way of ArcGIS.
Solution or Workaround
Recreate a table in the RDBMS having the same name and owner as the original, and delete it using ArcCatalog. This cleans up any existing entries in the GDB_* tables for the original object.
Create a new table in ArcSDE having the same name, owner, and database as the original table or feature class using the SDETABLE administrator command:
Code: sdetable -o create -t <name of original table> -d "test string(10)" -s <server name> -i <service name or ArcSDE port #> -u <owner name> -p <password> -D <database>
Connect as the owner of the new table in ArcCatalog.
Right-click on the table and select 'Delete'.
Now it should be possible to create a new table or feature class that has the same name as the original.