ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Truncate Table

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

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

Usage

    Caution:

    If a selection is applied to a layer or table view, the selection will be ignored and all records will be truncated.

  • Supported data types are simple points, lines, or polygons stored in a database. Complex data types such as terrains, topologies, and network datasets are not supported as input.

  • Versioned data is not supported as input. Data must be unregistered as versioned before the tool will execute successfully.

  • Truncate commands do not use database transactions and are unrecoverable. This improves performance over row-by-row deletion.

  • It is recommended that this tool be use for workflows in which all rows are removed from a table or feature class and there is no need to back up the transactions, such as nightly reloading of data.

Syntax

arcpy.management.TruncateTable(in_table)
ParameterExplanationData Type
in_table

The input database table or feature class that will be truncated.

Table View

Derived Output

NameExplanationData Type
out_table

The truncated table.

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("neil/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

  • Current Workspace

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics

  • An overview of the Table toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal