# Rebuild Action

The *Rebuild* action **entirely rebuilds an existing table** by creating a new physical table with the same schema and inserting all of its data into it.

It is mainly used to change field properties that cannot be modified once a table is built, most notably adding a **Required** or **Required + Identifier** constraint to an attribute (see [attribute constraints](/en/product/lakehouse-manager/tables/table-interactions?id=attribute-constraints)).

![rebuild-action-configuration](picts/rebuild-action-overview.png)

* [Why rebuild a table](#why-rebuild-a-table)
* [Configure a Rebuild action](#configure-a-rebuild-action)
  * [Default values](#default-values)
  * [Keep backup table](#keep-backup-table)

---
## Why rebuild a table

Rebuilding a table has several benefits:

- **Change field properties** such as *Required*, which [cannot be done once a table is built](/en/product/lakehouse-manager/tables/table-interactions?id=attribute-constraints).
- **Restructure partitioned data.** If the table uses partitions, all data is rewritten using those partitions. Note that when partitions are added to an existing table, only new data is stored under those partitions. The Rebuild action lets you properly restructure *all* of the data.
- **Clean metadata and storage.** All metadata and history is removed to keep a single clean version of the table. This can reduce storage and improve performance, as Iceberg optimizes the way it stores data.

!> The Rebuild action removes **all of the table's history**. Once it runs, you can no longer use the [Time Travel](/en/product/lakehouse-manager/tables/time-travel) feature to roll back to a previous version. It is a fresh start.

---
## Configure a Rebuild action

To create a new *Rebuild* action, navigate to the *Actions* tab of the Data Processing Engine (DPE), click on **New Action**, and select the *Rebuild* action. Then select the table to rebuild and adjust its field configuration (required flag, identifier flag, and default value).

![rebuild-configure](picts/rebuild-config.png)

### Default values

When changing an attribute's property to **Required** or **Required + Identifier**, you must set a **default value**. This value replaces any NULL values found for that attribute during the rebuild, ensuring the new required constraint is satisfied.

### Keep backup table

The **Keep backup table** option keeps a backup of the previous table, *with its history*. The backup table is named with the prefix `_back_{hash}` (for example, `my_table_back_d26433d4`). You can find this name in the execution logs.

---
###  Need help? 🆘

> If you are logging-in with an OVHcloud account, you can create a ticket to raise an incident or if you need support at the [OVHcloud Help Centre](https://help.ovhcloud.com/csm/fr-home?id=csm_index). Additionally, you can ask for support by reaching out to us on the Data Platform Channel within the [Discord Server](https://discord.com/channels/850031577277792286/1163465539981672559). There is a step-by-step guide in the [support](/en/support/index.md).
