2020-04-03 13:23:32 +00:00
---
2022-08-28 14:53:34 +00:00
slug: /en/sql-reference/table-functions/merge
2023-06-23 13:16:22 +00:00
sidebar_position: 130
2022-04-09 13:29:05 +00:00
sidebar_label: merge
2020-04-03 13:23:32 +00:00
---
2022-06-02 10:55:18 +00:00
# merge
2017-12-28 15:13:23 +00:00
2021-11-01 10:39:25 +00:00
Creates a temporary [Merge ](../../engines/table-engines/special/merge.md ) table. The table structure is taken from the first table encountered that matches the regular expression.
2017-12-28 15:13:23 +00:00
2021-11-01 10:39:25 +00:00
**Syntax**
```sql
2024-02-24 00:02:13 +00:00
merge(['db_name',] 'tables_regexp')
2021-11-01 10:39:25 +00:00
```
**Arguments**
2024-02-24 00:02:13 +00:00
- `db_name` — Possible values (optional, default is `currentDatabase()` ):
2023-06-23 13:16:22 +00:00
- database name,
2021-11-02 14:29:20 +00:00
- constant expression that returns a string with a database name, for example, `currentDatabase()` ,
- `REGEXP(expression)` , where `expression` is a regular expression to match the DB names.
2021-11-01 10:39:25 +00:00
- `tables_regexp` — A regular expression to match the table names in the specified DB or DBs.
**See Also**
2023-04-19 15:55:29 +00:00
- [Merge ](../../engines/table-engines/special/merge.md ) table engine