Sometimes, when inserting data in an oracle database, you need to determine whether the data already exists. First, execute the following SQL: selectcount (*) isExistsfromt_test_lll; then judge whether isExists is equal to 0. If it is equal to 0, execute insert. It can also be written in this way, but it can be written in multiple ways.
Sometimes, when inserting data in an oracle database, you need to determine whether the data already exists. First, execute the following SQL statement: select count (*) isExists from t_test_lll; then judge whether isExists is equal to 0. If it is equal to 0, execute insert. It can also be written in this way, but it can be written in multiple ways.
Sometimes, when inserting data in an oracle database, you need to determine whether the data already exists.
Our first thought is as follows: first, execute the following SQL:
Select count (*) isExists from t_test_lll;
Then determine whether isExists is equal to 0 or not. If isExists is equal to 0, insert is executed.
It can also be written like this, but writing a lot of code is not conducive to later maintenance.
In fact, oracle can be built into the insert statement for judgment, the following SQL:
Insertwists (not exists (select 1 from t_test_lll where id = '000000') theninto t_test_lll (id) select '000000' from dual;
In this way, when there is a record with id = '000000' in the database, the insert operation will not be performed.