insert into tbl(id,name)
values('GGG','ttt')
改成
select 'GGG','ttt'
where
not exists (
select id from tbl where id='GGG'
)
reference https://stackoverflow.com/questions/4069718/postgres-insert-if-does-not-exist-already