ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for 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
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Compact

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

Summary

Compacts a personal or file geodatabase. Compacting rearranges how the geodatabase is stored on disk, often reducing its size and improving performance.

Usage

  • It is recommended to compact personal geodatabases when they become larger than 250 MB.

  • If data entry, deletion, or general editing is frequently performed on a database, the database should be regularly compacted to ensure optimal performance.

  • If a database is open in ArcMap for editing, it cannot be compacted. To compact the database, remove any layers with a source table or feature class in that database from the Table of Contents.

  • Dive-in:

    Personal and file geodatabases are stored as binary files on a disk drive. As data is added, removed, or edited, these files become fragmented, decreasing overall database performance. The Compact tool is used to rearrange how the database is stored on disk by defragmenting these binary files, reducing the database's size on disk and improving database performance.

Syntax

Compact_management (in_workspace)
ParameterExplanationData Type
in_workspace

The personal or file geodatabase to be compacted.

Workspace

Code sample

Compact Example (Python Window)

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

import arcpy
arcpy.Compact_management("c:/landuse.gdb")
Compact Example 2 (stand-alone script)

The following stand-alone script is a simple example of how to use the Compact function in a scripting environment.

# Name: Compact_Example.py
# Description: compact a file geodatabase

#Import the system modules
import arcpy
from arcpy import env

env.workspace = "C:/data/data.gdb"

#Set local variables
gdbWorkspace = env.workspace
arcpy.Compact_management(gdbWorkspace)

Environments

  • Current Workspace
  • Output CONFIG Keyword
  • Scratch Workspace

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • Compress file geodatabase data
  • Compact file and personal geodatabases
  • An overview of the File Geodatabase toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal