通过管道将数据从clickhouse传输到运行在不同机器上的postgresql

svdrlsy4  于 2021-07-15  发布在  ClickHouse
关注(0)|答案(1)|浏览(531)

我的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数据库(在不同的机器上运行)?

bakd9h0s

bakd9h0s1#

clickhouse尚不支持写入odbc表(mysql有这个功能)。假设您在一台可以同时访问clickhouse客户端和psql的机器上同时拥有clickhouse客户端和psql <some-ip> 以及 <another_ip> . 你可以通过

clickhouse-client --host <some-ip> --port 8122 --query 'select * from chtable;' | psql -h <another_ip> -p 5437 -c 'copy psqltable from stdin'

相关问题