需求:根据输入的时间区间,搜寻A B两库的数据同一时间的数据差异
可能使用到的linux命令 diff psql脚本
issue1 :这个时间区间可以存储在表中?
先将A库的数据根据传入的条件group by 并将结果输出到file1 再将B库的数据根据传入的条件group by 并将结果输出到file2 select ope_id,count(1) from eda.wpp_asht_ope_his_n where logof_timestamp between '2021-04-12 05:00:00' and '2021-04-12 06:00:00' group by ope_id order by ope_id
变量为: ope_id, logof_timestamp ,table_name 时间区间
将 使用linux 命令将file1和file2的差集输出到 并集:cat file1.txt file2.txt | sort | uniq > file.txt 交集: cat file1.txt file2.txt | sort | uniq -d >file.txt 差集:求file1.txt相对于file2.txt的差集,可先求出两者的交集temp.txt,然后在 file1.txt中除去temp.txt即可。 cat file1.txt file2.txt | sort | uniq -d >temp.txt cat file1.txt temp.txt | sort | uniq -u >file.txt
差集的结果能得到站点和数量 A1100 168 此处得到的是file1 和file2 有差异的那一行 ?此处取的是file1 还是file2 都可以 主要是为了获取站点作为参数传入第二段sql