1. 程式人生 > >oracle insert指令碼新增判斷

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判斷