> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Creates a temporary Merge table. The structure will be derived from underlying tables by using a union of their columns and by deriving common types.

# merge

Creates a temporary [Merge](/reference/engines/table-engines/special/merge) table.
The table schema is derived from underlying tables by using a union of their columns and by deriving common types.
The same virtual columns are available as for the [Merge](/reference/engines/table-engines/special/merge) table engine.

<h2 id="syntax">
  Syntax
</h2>

```sql theme={null}
merge(['db_name',] 'tables_regexp')
```

<h2 id="arguments">
  Arguments
</h2>

| Argument        | Description                                                                                                                                                                                                                                                                                           |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `db_name`       | Possible values (optional, default is `currentDatabase()`):<br />    - database name,<br />    - constant expression that returns a string with a database name, for example, `currentDatabase()`,<br />    - `REGEXP(expression)`, where `expression` is a regular expression to match the DB names. |
| `tables_regexp` | A regular expression to match the table names in the specified DB or DBs.                                                                                                                                                                                                                             |

<h2 id="related">
  Related
</h2>

* [Merge](/reference/engines/table-engines/special/merge) table engine
