clickhouse增加删除列

----tbl_market_log_info_all
ALTER TABLE shard1.tbl_market_log_info_replication ADD COLUMN IF NOT EXISTS allConcat String Materialized concat('transDt=', transDt, '#^|discountId=', discountId, '#^|cardNo=', cardNo, '#^|mobile=', mobile, '#^|userId=', userId, '#^|logId=', logId, '#^|mchntCd=', ifNull(mchntCd,''), '#^|orderAt=', ifNull(orderAt,''), '#^|transChnl=', ifNull(transChnl,''), '#^|activityNm=', ifNull(activityNm,''), '#^|factor=', ifNull(factor,''), '#^|factorName=', ifNull(factorName,''), '#^|resultCd=', ifNull(resultCd,''), '#^|hostname=', ifNull(hostname,''), '#^|message=', ifNull(message,''), '#^|id=', ifNull(id,''), '#^|icTmn=', ifNull(icTmn,''), '#^|ruleTp=', ifNull(ruleTp,''), '#^|collectiontime=', ifNull(collectiontime,''), '#^|dataset=', ifNull(dataset,''), '#^|path=', ifNull(path,''), '#^|rownumber=', ifNull(rownumber,''), '#^|ip=', ifNull(ip,''), '#^|streamtype=', ifNull(streamtype,''), '#^|date=', ifNull(date,''), '#^|processtype=', ifNull(processtype,''), '#^|parsingtime=', ifNull(parsingtime,''), '#^|version=', ifNull(version,''), '#^|topic=', ifNull(topic,''), '#^|record=', ifNull(record,''));



ALTER TABLE _cw_distributed_db.tbl_market_log_info_all ADD COLUMN IF NOT EXISTS allConcat String Materialized concat('transDt=', transDt, '#^|discountId=', discountId, '#^|cardNo=', cardNo, '#^|mobile=', mobile, '#^|userId=', userId, '#^|logId=', logId, '#^|mchntCd=', ifNull(mchntCd,''), '#^|orderAt=', ifNull(orderAt,''), '#^|transChnl=', ifNull(transChnl,''), '#^|activityNm=', ifNull(activityNm,''), '#^|factor=', ifNull(factor,''), '#^|factorName=', ifNull(factorName,''), '#^|resultCd=', ifNull(resultCd,''), '#^|hostname=', ifNull(hostname,''), '#^|message=', ifNull(message,''), '#^|id=', ifNull(id,''), '#^|icTmn=', ifNull(icTmn,''), '#^|ruleTp=', ifNull(ruleTp,''), '#^|collectiontime=', ifNull(collectiontime,''), '#^|dataset=', ifNull(dataset,''), '#^|path=', ifNull(path,''), '#^|rownumber=', ifNull(rownumber,''), '#^|ip=', ifNull(ip,''), '#^|streamtype=', ifNull(streamtype,''), '#^|date=', ifNull(date,''), '#^|processtype=', ifNull(processtype,''), '#^|parsingtime=', ifNull(parsingtime,''), '#^|version=', ifNull(version,''), '#^|topic=', ifNull(topic,''), '#^|record=', ifNull(record,''));
----tbl_market_log_info_all





----------------insert

insert into shard1.upsf_ods_upb_tbl_market_activity_log_info_ulsp_replica(transDt,discountId,cardNo,mobile,userId,logId,mchntCd,orderAt,transChnl,activityNm,factor,factorName,resultCd,hostname,version) VALUES('2020-06-27 11:21:00','11','c1','13061771461','u1','log1','mchntCd1','orderAt1','transChnl1','activityNm1','factor1','factorName1','resultCd1','hostname1','version1');

insert into _cw_distributed_db.upsf_ods_upb_tbl_market_activity_log_info_ulsp(transDt,discountId,cardNo,mobile,userId,logId,mchntCd,orderAt,transChnl,activityNm,factor,factorName,resultCd,hostname,version) VALUES('2020-06-27 12:21:00','12','c1','13061771461','u1','log1','mchntCd1','orderAt1','transChnl1','activityNm1','factor1','factorName1','resultCd1','hostname1','version1');


-----------------select
select allConcat from  shard1.upsf_ods_upb_tbl_market_activity_log_info_ulsp_replica where discountId ='11';

transDt=2020-06-27 11:21:00#^|discountId=11#^|cardNo=c1#^|mobile=13061771461#^|userId=u1#^|logId=log1#^|mchntCd=mchntCd1#^|orderAt=orderAt1#^|transChnl=transChnl1#^|activityNm=activityNm1#^|factor=factor1#^|factorName=factorName1#^|resultCd=resultCd1#^|hostname=hostname1#^|message=#^|id=#^|icTmn=#^|ruleTp=#^|collectiontime=#^|dataset=#^|path=#^|rownumber=#^|ip=#^|streamtype=#^|date=#^|processtype=#^|parsingtime=#^|version=version1#^|topic=#^|record=

transDt=2020-06-27 12:21:00#^|discountId=12#^|cardNo=c1#^|mobile=13061771461#^|userId=u1#^|logId=log1#^|mchntCd=mchntCd1#^|orderAt=orderAt1#^|transChnl=transChnl1#^|activityNm=activityNm1#^|factor=factor1#^|factorName=factorName1#^|resultCd=resultCd1#^|hostname=hostname1#^|message=#^|id=#^|icTmn=#^|ruleTp=#^|collectiontime=#^|dataset=#^|path=#^|rownumber=#^|ip=#^|streamtype=#^|date=#^|processtype=#^|parsingtime=#^|version=version1#^|topic=#^|record=

select allConcat from  _cw_distributed_db.tbl_market_log_info_all where discountId ='d2';


show create table _cw_distributed_db.tbl_market_log_info_all ;

show create table "_cw_distributed_db"."tbl_market_activity_log_info_ulsp";

-----------------drop
ALTER TABLE _cw_distributed_db.tbl_market_log_info_all DROP COLUMN IF EXISTS allConcat;
ALTER TABLE _cw_distributed_db.upsf_ods_upb_tbl_market_activity_log_info_ulsp DROP COLUMN IF EXISTS allConcat;



ALTER TABLE shard1.upsf_ods_upb_tbl_market_activity_log_info_ulsp_replica DROP COLUMN IF EXISTS allConcat;
ALTER TABLE shard2.upsf_ods_upb_tbl_market_activity_log_info_ulsp_replica DROP COLUMN IF EXISTS allConcat;
ALTER TABLE shard3.upsf_ods_upb_tbl_market_activity_log_info_ulsp_replica DROP COLUMN IF EXISTS allConcat;

ALTER TABLE shard1.tbl_market_log_info_replication DROP COLUMN IF EXISTS allConcat;
ALTER TABLE shard2.tbl_market_log_info_replication DROP COLUMN IF EXISTS allConcat;
ALTER TABLE shard3.tbl_market_log_info_replication DROP COLUMN IF EXISTS allConcat;

原文地址:https://www.cnblogs.com/tonggc1668/p/14986949.html