Is there a way to delete a feature data set and all of its feature classes programmatically either by using custom code or pre-existing command line tools?

There is a tool provided by SDE called sdetable.exe but i'm not sure if this will do the trick.

My feature data sets are setup in ArcSDE via scripts which call a custom executable that imports XML workspaces. I'd like a way to delete the feature data sets that the XML workspaces import because when I re-run the scripts I get things like this:

Underlying DBMS error [ORA-00972: identifier is too long


The '_1' is appended because there is already a feature class named Surface_Drainage_Channel_Area. So I'd like to have my scripts first drop the VITD feature data set and all of its feature classes before importing my XML workspace XML document that creates it.

  • You could certainly call your python script written in ArcPy or exported from ArcToolbox. – Place - Zilla Mar 30 '11 at 14:21

sdetable (like all SDE command line tools) does not recognize/understand the Geodatabse. Because a feature dataset is a geodatabase object, you cannot use sdetable to delete it.

You'll need to stick with an ArcObjects based client to do a clean delete. The easiest way would be to use the delete geoprocessing tool.


Thanks for pointing me in the right direction. Here is the ArcPy script I wrote that worked for me:

# Name:        RemoveSdeObjects.py
# Purpose:     Removes all feature datasets, classes and tables for a given user
# Author:      Andy Arismendi
# Created:     23/06/2011
#!/usr/bin/env python

from optparse import OptionParser
import sys
import os.path
import arcpy
from arcpy import env

def RemoveAllSdeObjects (workspace, user):
    import arcpy
    from arcpy import env

    env.overwriteOutput = True
    env.workspace = workspace

        datasetList = arcpy.ListDatasets((user + ".*"), "All")

        # Check if the connection failed.
        # Look for message: 'WARNING 000565: Could not connect to server.'
        connMsg = arcpy.GetMessage(2)
        if ('WARNING 000565:' in connMsg):
            raise Exception(connMsg)

        for dataset in datasetList:

        featureClassList = arcpy.ListFeatureClasses((user + ".*"), "All")
        for featureClass in featureClassList:

        tableList = arcpy.ListTables((user + ".*"), "All")
        for table in tableList:
        raise Exception(arcpy.GetMessages() + "\n")
        env.workspace = ""

def main():
    # Process parameters.
        usage = "usage: %prog [options]"
        parser = OptionParser(usage=usage)

            "-s", action="store", type="string", dest="server",
                help="The SDE server name or IP address.")

            "-i", action="store", type="int", dest="port",
                help="The SDE instance port number.")

            "-u", action="store", type="string", dest="username",
                help="The schema owner username.")

            "-p", action="store", type="string", dest="password",
                help="The schema owner password.")

        (options, args) = parser.parse_args()

        # All parameters are required.
        if options.server == None:
            parser.error("Missing required parameter: '-s SDE_SERVER'.")
        if options.port == None:
            parser.error("Missing required parameter: '-i SDE_PORT'.")
        if options.username == None:
            parser.error("Missing required parameter: '-u SCHEMA_OWNER_USERNAME'.")
        if options.password == None:
            parser.error("Missing required parameter: '-p SCHEMA_OWNER_PASSWORD'.")

        sdeConnectionFileDir = os.environ.get("TEMP")
        if sdeConnectionFileDir == None:
            raise Exception("Required environment variable is not defined: 'TEMP'.")

        databaseName = ""
        fileName = options.username + " to " + options.server + ".sde"

        # Delete any pre-existing SDE connection file.
        fullPath = sdeConnectionFileDir + '\\' + fileName
        if os.path.exists(fullPath):

        # Create temporary SDE connection file.
            arcpy.CreateArcSDEConnectionFile_management (
                sdeConnectionFileDir, fileName,
                options.server, options.port, options.server,
                "DATABASE_AUTH", options.username, options.password,
                "SDE.DEFAULT", "SAVE_VERSION"
            raise Exception(arcpy.GetMessages() + "\n")

        # Remove all SDE objects owned by this user.
        RemoveAllSdeObjects(fullPath, options.username)

        # Remove temporary SDE connection file.
    except Exception as e:
        print "Failed to remove SDE objects.", e

if __name__ == '__main__':

You will have to delete the featureclasses first, then the container featuredataset. The featuredataset will have to be empty before you can delete it. You might want to look at the IDataset.Delete method

  • Why does the feature dataset have to be empty? Is that so that you cover the case where a feature dataset contains a topology or geometric network which would prevent the feature dataset from being deleted? – Derek Swingley Mar 16 '11 at 20:55
  • @Swingley - I guess it's just like deleting a FD in ArcCatalog - has to be empty of FCs first. – Chad Cooper Mar 16 '11 at 21:08
  • @Chad- If you only have simple features in your feature dataset, you can delete the feature dataset without deleting the feature classes first. – Derek Swingley Mar 16 '11 at 21:13
  • @Swingley-Really? Well, I stand corrected! I'll have to try that. – Chad Cooper Mar 16 '11 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.