ClickHouse/docs/en/engines/table-engines/integrations/materialize-postgresql.md

37 lines
1.2 KiB
Markdown
Raw Normal View History

2021-04-11 20:26:59 +00:00
---
toc_priority: 12
toc_title: MateriaziePostgreSQL
---
# MaterializePostgreSQL {#materialize-postgresql}
## Creating a Table {#creating-a-table}
2021-05-04 10:43:21 +00:00
``` sql
CREATE TABLE test.postgresql_replica (key UInt64, value UInt64, _sign Int8 MATERIALIZED 1, _version UInt64 MATERIALIZED 1)
ENGINE = MaterializePostgreSQL('postgres1:5432', 'postgres_database', 'postgresql_replica', 'postgres_user', 'postgres_password')
PRIMARY KEY key;
```
2021-04-11 20:26:59 +00:00
## Requirements {#requirements}
2021-05-04 10:43:21 +00:00
- Setting `wal_level`to `logical` and `max_replication_slots` to at least `2` in the postgresql config file.
- A table with engine `MaterializePostgreSQL` must have a primary key - the same as a replica identity index (default: primary key) of a postgres table (See [details on replica identity index](../../database-engines/materialize-postgresql.md#requirements)).
2021-04-11 20:26:59 +00:00
- Only database `Atomic` is allowed.
2021-05-04 10:43:21 +00:00
## Virtual columns {#creating-a-table}
- `_version`
- `_sign`
``` sql
CREATE TABLE test.postgresql_replica (key UInt64, value UInt64, _sign Int8 MATERIALIZED 1, _version UInt64 MATERIALIZED 1)
ENGINE = MaterializePostgreSQL('postgres1:5432', 'postgres_database', 'postgresql_replica', 'postgres_user', 'postgres_password')
PRIMARY KEY key;
```