Partager via


PACK Command

Permanently removes all records marked for deletion in the current table and reduces the size of a memo file associated with the table.

PACK [MEMO] [DBF] [Tablename ] [IN nWorkarea | cTableAlias]

Parameters

  • MEMO
    Removes unused space from the memo file but doesn't remove records marked for deletion from the table. Information in memo fields is stored in an associated memo file. A memo file has the same name as the table and an .fpt extension.
  • DBF
    Removes records marked for deletion from the table but doesn't affect the memo file.
  • Tablename
    Specifies the table to pack. Visual FoxPro opens the specified table, then packs, and closes it.
  • IN nWorkArea | cTableAlias
    Specifies the workarea or table alias affected by the PACK command. Use this clause to specify a workarea or a table outside the current work area.

Remarks

When you use PACK, Microsoft Visual FoxPro copies all records not marked for deletion to a temporary table. After PACK is finished executing, Visual FoxPro deletes the original table from disk and renames the temporary table with the original table name. If you press ESC to interrupt PACK, the temporary table is deleted, and the original table remains unchanged. The original table is also recovered if you run out of disk space while PACK is executing.

When you issue PACK without the MEMO and DBF clauses, PACK affects both the table and the memo file.

PACK requires exclusive use of the table. For more information about opening a table exclusively on a network, see SET EXCLUSIVE.

If the current table has one or more indexes open, PACK rebuilds the index files.

Caution   Be careful to mark only records that you no longer need. There is no way to retrieve deleted records after using PACK.

If you omit the IN clause, PACK works in the current work area.

When you use PACK with a table containing autoincrementing fields, the resulting table is not reincremented, that is, existing values are preserved, and gaps exist where deleted records were removed. For more information, see Autoincrementing Field Values in Tables.

See Also

DELETE – SQL | DELETE | DELETED( ) | RECALL | SET EXCLUSIVE