Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Everything is in the title. I need to truncate file geodatabase tables (1 or all) with python. What is the code for that? Thank you in advance!

share|improve this question
up vote 5 down vote accepted

AFAIK, you can use Delete Rows method in arcpy. from Arcgis Resource Center:

Delete Rows (Data Management)


Deletes all or the selected subset of rows from the input.

If the input rows are from a feature class or table, all rows will be deleted. If the input rows are from a layer or table view with no selection, all rows will be deleted.

consider this caution:

If run against a layer or table view that does not have a selection, the operation cannot be undone using undo/redo.

Example Code:

import arcpy
from arcpy import env

env.workspace = "C:/data"
arcpy.CopyRows_management("accident.dbf", "C:/output/accident2.dbf")

i hope it helps you...

share|improve this answer

As of 10.1, Esri has added Truncate Table (Data Management). It will remove all records from a table, regardless of a table view selection, and does not support versioned tables. It is much faster, though.

Esri's sample code for truncating all tables in a geodatabase:

# 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:
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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