Delete (Data Management)

Summary

Permanently deletes data. All types of geographic data supported by ArcGIS, as well as toolboxes and workspaces (folders and geodatabases), can be deleted. If the specified item is a workspace, all contained items are also deleted.

Usage

  • Data currently in use in another ArcGIS application cannot be deleted.

  • Deleting a shapefile also deletes ancillary files such as the metadata, projection, and index files.

  • Deleting a folder moves the folder to the system Recycle Bin, where it can be restored or permanently deleted.

  • Feature classes and tables participating in a network analysis dataset or a topology cannot be deleted.

  • Deleting a mosaic dataset will only delete the mosaic dataset. To delete a mosaic dataset in its entirety—including any tables in the database and, optionally, any overviews or caches created with it—use the Delete Mosaic Dataset tool.

  • Deleting a database connection file does not delete the enterprise database. A database connection file is simply a shortcut to the database.

  • Deleting a relationship class deletes the row corresponding to that relationship from the relationship table.

  • Deleting a layer removes only the layer; its source data is not deleted.

  • This tool does not delete hosted feature services.

  • This tool can be used to delete the memory workspace. When the memory workspace is deleted, all datasets in the workspace are deleted, but the memory workspace remains, allowing you to continue writing to it.

Parameters

LabelExplanationData Type
Input Data Element

The input data to be deleted.

Data Element; Graph; Layer; Table View; Utility Network
Data type
(Optional)

The type of data on disk to be deleted.

This parameter will be used in the event of a name conflict. A geodatabase may contain different datasets with the same name, for example, a feature class, feature dataset, mosaic dataset, and parcel fabric with the same name may exist in the same geodatabase. Specifying a value will direct the tool to use that data type in the event of two or more datasets with the same name.

  • FeatureClass—In the event of duplicate names, the feature class will be used.
  • FeatureDataset—In the event of duplicate names, the feature dataset will be used.
  • MosaicDataset—In the event of duplicate names, the mosaic dataset will be used.
  • ParcelFabric—In the event of duplicate names, the parcel fabric will be used.
String

Derived Output

LabelExplanationData Type
Delete Succeeded

Whether the delete was successful.

Boolean

arcpy.management.Delete(in_data, {data_type})
NameExplanationData Type
in_data
[in_data,...]

The input data to be deleted.

Data Element; Graph; Layer; Table View; Utility Network
data_type
(Optional)

The type of data on disk to be deleted.

This parameter will be used in the event of a name conflict. A geodatabase may contain different datasets with the same name, for example, a feature class, feature dataset, mosaic dataset, and parcel fabric with the same name may exist in the same geodatabase. Specifying a value will direct the tool to use that data type in the event of two or more datasets with the same name.

  • FeatureClass—In the event of duplicate names, the feature class will be used.
  • FeatureDataset—In the event of duplicate names, the feature dataset will be used.
  • MosaicDataset—In the event of duplicate names, the mosaic dataset will be used.
  • ParcelFabric—In the event of duplicate names, the parcel fabric will be used.
String

Derived Output

NameExplanationData Type
out_results

Whether the delete was successful.

Boolean

Code sample

Delete example (Python window)

The following Python window script demonstrates how to use the Delete function in immediate mode.


import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.Copy("majorrds.shp", "majorrdsCopy.shp")
arcpy.management.Delete("majorrdsCopy.shp")
Delete example 2 (stand-alone script)

The following Python script demonstrates how to use the Delete function in a stand-alone script.

# Name: Delete_Example2.py
# Description: Delete majorrdsCopy.shp 

# Import system modules
import arcpy

# Set workspace
arcpy.env.workspace = "C:/data"

# Set local variables
in_data = "majorrds.shp"
out_data = "majorrdscopy.shp"

# Run Copy
arcpy.management.Copy(in_data, out_data)

# Run Delete
arcpy.management.Delete(out_data)
Delete example 3 (Python window)

The following Python window script demonstrates how to use the Delete function with multiple inputs in immediate mode.


import arcpy
arcpy.env.workspace = r"C:\dataToDelete"
arcpy.management.Delete(r"'NIRrG_ps8.afr';'redlands.tpkx';'colormap.img'")

Environments

This tool does not use any geoprocessing environments.