Oracle 与 SQL Server的简单常用的插入语句的区别

--Oracle的方式判断记录是否存在不存在则插入---
insert into a(a.user_id,a.user_name) select '2','李四' from dual where not exists
(select 1 from a where a.user_id='2')


--sql server的方式--
if not exists(select Test_TB.ID from Test_TB where ID='2')
  insert into Test_TB values('2','李四',GETDATE())

相关推荐