# replace

open fun <T : Table> T.replace(body: T.(UpdateBuilder<*>) -> Unit): ReplaceStatement<Long>

Represents the SQL statement that either inserts a new row into a table, or, if insertion would violate a unique constraint, first deletes the existing row before inserting a new row.

Note: This operation is not supported by all vendors, please check the documentation.

#### Return

A ReplaceStatement that can be executed.

open fun <T : Table> T.replace(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): ReplaceSelectStatement

Represents the SQL statement that uses data retrieved from a selectQuery to either insert a new row into a table, or, if insertion would violate a unique constraint, first delete the existing row before inserting a new row.

Note: This operation is not supported by all vendors, please check the documentation.

#### Return

A ReplaceSelectStatement that can be executed.

#### Parameters

selectQuery

Source `SELECT` query that provides the values to insert.

columns

Columns to either insert values into or delete values from then insert into. This defaults to all columns in the table that are not auto-increment columns without a valid sequence to generate new values.