1、第一步,打开plsql,然后创建一个t_test_lll 表

2、第二步,插入一条ID为aa的记录,执行语句如下图

3、第三步,执行如下判断SQL:
insert when (not exists (select 1 from t_test_lll where id = 'aa')) then
into t_test_lll(id) select 'aa' from dual;
可见当数据库里已存在一个id='aa'的记录的时候,就不会进行insert操作。

时间:2026-02-12 08:01:40
1、第一步,打开plsql,然后创建一个t_test_lll 表

2、第二步,插入一条ID为aa的记录,执行语句如下图

3、第三步,执行如下判断SQL:
insert when (not exists (select 1 from t_test_lll where id = 'aa')) then
into t_test_lll(id) select 'aa' from dual;
可见当数据库里已存在一个id='aa'的记录的时候,就不会进行insert操作。
