Llinux shell heredoc使用

  • 直接上例子
/home/postgres/pgsql/bin/psql -Upostgres -d efc -c "DROP TABLE tbl_event_record_2019_11_03_03"

SQL=`cat <<-EOF
explain(verbose, analyse)
insert into tbl_event_record(
event_id,
event_type,
event_source,
dev_code,
active_name,
event_security,
event_time,
alarm_status,
check_time,
check_user,
ack_time,
ack_user,
ack_suggestion,
key_value,
event_desc,
is_misinform,
is_plan_alarm,
is_once_plan_alarm,
security_name,
security_color,
user_code_list,
event_record_time)
select n , n, 'event_source', 'dev_code','active_name',n,now(), n, 'check_time','check_user','ack_time',
'ack_user','ack_suggestion','key_value','event_desc',n,n,n,'security_name','security_color','{hello,world}',now()
from generate_series(1,10000) as t(n) ;
EOF
/home/postgres/pgsql/bin/psql -Upostgres -d efc -c "$SQL"
posted @ 2019-11-05 18:46  岳麓丹枫  阅读(351)  评论(0编辑  收藏  举报