在不同机器上将数据从 clickhouse 传输到 PostgreSQL 运行
Transfer data from clickhouse to PostgreSQL running on different machines
我的 clickhouse 数据库在 some_ip:8122
上运行
clickhouse 数据库:
create table chtable
(
val_1 UInt32,
val_2 UInt32,
val_date_full DateTime,
val_id UInt64,
val_date_short Date
)
engine = MergeTree(val_date_short, val_id , 8192);
我的 postgresql 数据库在 another_ip:5437
上运行
postgresql 数据库:
create table psqltable
(
val_1 integer,
val_2 integer,
val_date_full timestamp,
val_id integer,
val_date_short date
val_id integer not null,
val_date_short date not null,
constraint psqltable_pkey
primary key (val_date_short, val_id)
);
如何将数据从 clickhouse 数据库复制到 postgresql 数据库(运行 在不同的机器上)?
Clickhouse 尚不支持写入 ODBC 表。 (mysql 具有此功能)。假设您在某台可以同时访问 <some-ip>
和 <another_ip>
的机器上同时安装了 clickhouse-client 和 psql。您可以通过
实现
clickhouse-client --host <some-ip> --port 8122 --query 'select * from chtable;' | psql -h <another_ip> -p 5437 -c 'copy psqltable from stdin'
我的 clickhouse 数据库在 some_ip:8122
clickhouse 数据库:
create table chtable
(
val_1 UInt32,
val_2 UInt32,
val_date_full DateTime,
val_id UInt64,
val_date_short Date
)
engine = MergeTree(val_date_short, val_id , 8192);
我的 postgresql 数据库在 another_ip:5437
postgresql 数据库:
create table psqltable
(
val_1 integer,
val_2 integer,
val_date_full timestamp,
val_id integer,
val_date_short date
val_id integer not null,
val_date_short date not null,
constraint psqltable_pkey
primary key (val_date_short, val_id)
);
如何将数据从 clickhouse 数据库复制到 postgresql 数据库(运行 在不同的机器上)?
Clickhouse 尚不支持写入 ODBC 表。 (mysql 具有此功能)。假设您在某台可以同时访问 <some-ip>
和 <another_ip>
的机器上同时安装了 clickhouse-client 和 psql。您可以通过
clickhouse-client --host <some-ip> --port 8122 --query 'select * from chtable;' | psql -h <another_ip> -p 5437 -c 'copy psqltable from stdin'