clickhouse如何获取表结构
输出表名:
clickhouse-client --host 192.168.1.136 --port=9000 --password 123456 --multiquery --query="use db_test;show tables;"> /tmp/db_pushmsg.txt
输出表结构
[root@localhost scripts]# more echo_table_ck.sh
#!/bin/bash
tablelist_file=db_test.txt
table_ddl_sql=ddl_db_test.sql
db_name=db_test
echo 'use db_test;' >> ${table_ddl_sql}
cat ${tablelist_file} |while read eachline
do
clickhouse-client --host 192.168.1.251 --port=9000 --password 123456 --multiquery --query="use ${db_name};show create table $eachline;">> ${table_ddl_sql}
echo ';' >> ${table_ddl_sql}
done
##sed -i -e 's/\\n/ /g; s/\\//g;' ${table_ddl_sql}
##sed -i -e 's/\\n/ /g; s/\\//g; s/\\'\|'\|'\''//g' ${table_ddl_sql}
sed 's/\\n/ /g; s/\\//g;' ${table_ddl_sql}>>ddl_last.txt