1. 程式人生 > >SQLSERVER 和 ORACLE的if not exist 用法

SQLSERVER 和 ORACLE的if not exist 用法

sql server:

  if not exists (select 1 from TB_Procedure where Id='2018ZZZ')
BEGIN
  insert into TB_Procedure
        
 (Id,IsStart,IsCNC,IsClean,IsMarking,IsLT,IsGil,IsCheck,IsFinalCheck,IsGP12,IsPackaging)
		values
		( '2018ZZZ','','','','','','','','','','');
END

  

oracle:

insert into kszx_xjtm (id,unitid)   
SELECT 1,'1' FROM dual WHERE not exists  
(select * from kszx_xjtm where tmid = '1' )