Summary
Permanently deletes data from disk. All types of geographic data supported by ArcGIS, as well as toolboxes and workspaces (folders, 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—the tool fails with ERROR 000464.
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.
Deleting a geometric network demotes all the feature classes in the network to simple feature types; Edge feature classes become line feature classes; and junction feature classes become point feature classes. Deleting the network also deletes all the related network tables and the orphan junction feature class from the geodatabase.
Deleting a mosaic dataset will only delete the mosaic dataset itself and not any associated items.
The Delete Mosaic Dataset tool deletes associates items such as mosaic dataset overviews, item cache, and broken references.
Deleting a database connection file does not delete the ArcSDE 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.
Syntax
Delete_management (in_data, {data_type})
Parameter | Explanation | Data Type |
in_data | The input data to be deleted. | Data Element; Graph; Layer; Table View |
data_type (Optional) | Data type of the Input Data Element. Data type is displayed for informative purposes and cannot be changed. | String |
Code sample
Delete Example (Python Window)
The following Python Window script demonstrates how to use the Delete function in immediate mode.
import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.Copy_management(("majorrds.shp"), "majorrdsCopy.shp")
arcpy.Delete_management("majorrdsCopy.shp")
Delete Example 2 (Stand-alone Python 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
from arcpy import env
# Set workspace
ENV.workspace = "C:/data"
# Set local variables
in_data0 = "majorrds.shp"
out_data = "majorrdscopy.shp"
data_type = ""
# Execute Copy
arcpy.Copy_management(in_data, out_data, data_type)
# Execute Delete
arcpy.Delete_management(out_data, data_type)
Delete Example 3 (Python Window)
You can use the Delete tool to delete the in_memory workspace. When you delete the in_memory workspace, all datasets in the workspace are deleted, but the in_memory workspace remains, allowing you to continue writing to it.
import arcpy
arcpy.Delete_management("in_memory")
Environments
This tool does not use any geoprocessing environments
Licensing information
- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes