clickhouse如何表結構

slnngk發表於2024-04-22

輸出表名:

clickhouse-client --host 192.168.1.136 --port=9000 --password 123456 --multiquery --query="use db_pushmsg;show tables;"> /tmp/db_pushmsg.txt 

輸出表結構

#!/bin/bash
echo  'use db_pushmsg;' >> /tmp/db_pushmsg_tableDDL.sql

cat /tmp/db_pushmsg.txt |while read eachline
do
clickhouse-client --host 192.168.1.136 --port=9000 --password 123456 --multiquery --query="use db_pushmsg;show create table $eachli
ne;">> /tmp/db_pushmsg_tableDDL.sql
echo ';' >> /tmp/db_pushmsg_tableDDL.sql
done


sed -i -e 's/\\n/ /g; s/\\//g; s/\\'\|'\|'\''//g' /tmp/db_pushmsg_tableDDL.sql

相關文章