Truncate Table (Data Management)

License Level:BasicStandardAdvanced

Summary

Removes all rows from a database table or feature class using truncate procedures in the database.

Usage

Syntax

TruncateTable_management (in_table)
ParameterExplanationData Type
in_table

Input database table or feature class that will be truncated.

Table View

Code Sample

TruncateTable example 1 (Python window)

The following Python window script demonstrates how to use the TruncateTable tool in immediate mode.

import arcpy
arcpy.TruncateTable_management("Database Connections/whistler.sde/function.junction.table")
TruncateTable example 2 (stand-alone script)

The following Python window script demonstrates how to use the TruncateTable tool.

# Name: TruncateTable_Example2.py
# Description: Truncates all tables in a file geodatabase.

# Import system modules
import arcpy

# Set the workspace.
arcpy.env.workspace = "C:/work/vancouver.gdb"

# Get a list of all the tables.
tableList = arcpy.ListTables()

# Loop through the list and run truncate
for table in tableList:
    arcpy.TruncateTable_management(table)

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
11/18/2013