oracle insert脚本添加判断

insert

when (not exists (select 1 from t_test_lll where id = '111')) then

into t_test_lll(id) select '111' from dual;

insert

当(不存在(select 1 from 表名 where id= ‘111’))时

into 表名(字段名) select ‘字段值’ from dual(临时表)

第二种方法:

INSERT INTO DATA_CHANGE_LOG
(id) --插入的列
SELECT '888' --插入的值
FROM dual
WHERE not exists 
(select * from DATA_CHANGE_LOG where id = '999');--判断条件

普通的insert语句+where判断

猜你喜欢

转载自blog.csdn.net/qq3892997/article/details/82753728