oracle :
insert
when (not exists (select id from t_company_staff where name='赵国军4')) then
into t_company_staff (name,status,APPLIEDTYPE) select '赵国军4',2,1 from dual;
或者
insert
into t_company_staff
(name,status,APPLIEDTYPE) select '赵国军4',2,1 from dual where not exists (select id from t_company_staff where name='赵国军4')
postgresql:
insert
into t_company_staff
(name,status,APPLIEDTYPE) select '赵国军4',2,1 from dual where not exists (select id from t_company_staff where name='赵国军4')
注意:并发高的时候,可以尝试加睡眠时间来优化限制
博客给出了Oracle和PostgreSQL数据库插入数据的示例。在Oracle中,提供了两种插入方式,当表中不存在指定姓名记录时插入数据。在PostgreSQL中,也给出了类似的插入语句。同时提醒在并发高时,可尝试加睡眠时间来优化限制。
1625

被折叠的 条评论
为什么被折叠?



