# Table Output

The **Table Output** step loads data into a database table. Table Output is equivalent to the SQL `INSERT` operator.

* If you only need to update rows, use the [Update](https://pentaho-community.atlassian.net/wiki/spaces/EAI/pages/371558127/Update) step.
* To perform both `INSERT` and `UPDATE`, use [Insert/Update](https://pentaho-community.atlassian.net/wiki/spaces/EAI/pages/371558126/Insert+-+Update).

This step provides configuration options for a target table and performance-related options such as **Commit size** and **Use batch update for inserts**.

{% hint style="info" %}
If you insert a record into a database table that has identity columns, the JDBC driver might return the auto-generated key. This is not supported on all database types.
{% endhint %}

### General

| Option                      | Description                                                                                                                                                                                                                                |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Step name**               | Specifies the unique name of the Table Output step on the canvas. You can customize the name or leave it as the default.                                                                                                                   |
| **Connection**              | <p>Select the database connection where data will be written.</p><p>If you do not have an existing connection, select <strong>New</strong> or <strong>Wizard</strong>. To modify an existing connection, select <strong>Edit</strong>.</p> |
| **Target schema**           | Database schema name.                                                                                                                                                                                                                      |
| **Target table**            | Table name where data is written.                                                                                                                                                                                                          |
| **Commit size**             | Number of `INSERT` statements to run before sending a `COMMIT` command. Transactions are not supported on all database platforms.                                                                                                          |
| **Truncate table**          | Select to truncate the table before the first row is inserted. If you run multiple copies or clusters, truncate before running the transformation.                                                                                         |
| **Ignore insert errors**    | Select to ignore insert errors such as primary key violations. A maximum of 20 warnings are logged. Not available for batch inserts.                                                                                                       |
| **Specify database fields** | Select to define fields in the **Database fields** section. Required to use **Get fields** and **Enter field mapping**.                                                                                                                    |
| **SQL** (button)            | Opens the [Simple SQL Editor](/pdia-data-integration/archived-merged-pages/transforming-data-with-pdi-archive/logging-and-performance-monitoring/use-the-sql-editor.md), which can generate SQL to create the output table.                |

### Main options

| Option                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Partition data over tables**                        | Split data over multiple tables based on a date field specified in **Partitioning field**. Target table names follow `<target-table>_<date-format>`. You must create these tables before running the transformation.                                                                                                                                                                                                                 |
| **Partitioning field**                                | Date field used to generate dated table names when partitioning.                                                                                                                                                                                                                                                                                                                                                                     |
| **Partition data per month / Partition data per day** | Table name date format: `yyyyMM` (month) or `yyyyMMdd` (day).                                                                                                                                                                                                                                                                                                                                                                        |
| **Use batch update for inserts**                      | <p>Select to group <code>INSERT</code> statements into batches to reduce round trips.</p><p>Batch mode is used only when:</p><ul><li><strong>Use batch update for inserts</strong> is selected</li><li><strong>Commit size</strong> is greater than 0</li><li><strong>Return auto-generated key</strong> is cleared</li><li>The transformation does not use unique connections</li><li>The database supports batch updates</li></ul> |
| **Is the name of the table defined in a field?**      | Select to take the target table name from a field (specified in **Field that contains name of table**).                                                                                                                                                                                                                                                                                                                              |
| **Field that contains name of table**                 | Field that contains the target table name for the current row.                                                                                                                                                                                                                                                                                                                                                                       |
| **Store the table name field**                        | Select to store the table name in the output. The table must contain a column with the name defined by **Field that contains name of table**.                                                                                                                                                                                                                                                                                        |
| **Return auto-generated key**                         | Select to return the key generated by inserting a row into the table.                                                                                                                                                                                                                                                                                                                                                                |
| **Name of auto-generated key field**                  | Output field name for the auto-generated key.                                                                                                                                                                                                                                                                                                                                                                                        |

### Database fields

The **Database fields** section specifies which stream fields are inserted into which database columns.

| Field                            | Description                                                                    |
| -------------------------------- | ------------------------------------------------------------------------------ |
| **Table field**                  | Database column that receives the data.                                        |
| **Stream field**                 | Incoming stream field whose value is inserted.                                 |
| **Get fields** (button)          | Imports incoming fields into the table (requires **Specify database fields**). |
| **Enter field mapping** (button) | Opens the field mapping window (requires **Specify database fields**).         |

### Enter field mapping

| Field                            | Description                                                                                                                       |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **Source fields**                | Field names from the incoming stream.                                                                                             |
| **Target fields**                | <p>Fields in the output table.</p><p>When using this step with Spark on AEL, output field types are converted for processing.</p> |
| **Add** (button)                 | Adds the selected source and target pair to **Mappings**.                                                                         |
| **Delete** (button)              | Removes the selected mapping.                                                                                                     |
| **Mappings**                     | Field-to-column mappings.                                                                                                         |
| **Auto target selection?**       | Automatically select a target.                                                                                                    |
| **Hide assigned source fields?** | Hide a source field after it is mapped.                                                                                           |
| **Auto source selection**        | Automatically select a source field when a target column is selected.                                                             |
| **Hide assigned target fields?** | Hide a target column after it is mapped.                                                                                          |
| **Guess** (button)               | Automatically matches fields and populates **Mappings**.                                                                          |

### Metadata injection support

You can use [ETL metadata injection](/pdia-data-integration/pdi-transformation-steps-reference-overview/etl-metadata-injection.md) to pass metadata at runtime.

The following fields support metadata injection.

**Options**

* Target schema
* Target table
* Commit size
* Partitioning field
* Store the table name field
* Name of auto-generated key field
* Truncate table
* Specify database fields
* Ignore insert errors
* Use batch update for inserts
* Partition data over tables
* Partition data per
* Is the name of table defined in a field
* Return auto-generated key
* Connection

**Database fields**

* Table field
* Stream field


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pentaho.com/pdia-data-integration/pdi-transformation-steps-reference-overview/table-output.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
