如何在oracle中 insert into 多条记录??

lirq12345 2016-06-26 03:55:11
我想在两个数据表(cim_customer, cim_erp_adress)中找出a表(cim_erp_address表)中不存在的内容, 再用insert语句把不存在的信息加进表里。所以写了如下语句,执行时出现:“单行子查询返回多于一个行”


insert into cim_erp_address (customer_id,address_type,id_fragment,modify_date) values ((select t.customer_id from cim_customer t
where t.customer_id not in (select a.customer_id from cim_erp_address a)),2,'N','2007-10-15 10:31:24');
commit;


各位大神帮看一下,能不能有什么办法批量加入这些内容。最好是能以原来的
...全文
6724 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiezhang__zj 2016-08-10
  • 打赏
  • 举报
回复
insert 用法 insert into cim_erp_address (customer_id,address_type,id_fragment,modify_date) select t.customer_id,2,'N','2007-10-15 10:31:24' from cim_customer t where not exists(select 1 from cim_erp_address a where t.customer_id=a.customer_id);
Renkey 2016-07-01
  • 打赏
  • 举报
回复
同上 insert into cim_erp_address (customer_id,address_type,id_fragment,modify_date) select t.customer_id,2,'N','2007-10-15 10:31:24' from cim_customer t where not exists(select 1 from cim_erp_address a where t.customer_id=a.customer_id);
桃花岛黄岛主 2016-06-28
  • 打赏
  • 举报
回复
insert into cim_erp_address (customer_id,address_type,id_fragment,modify_date) 
select t.customer_id,2,'N','2007-10-15 10:31:24' from cim_customer t
 where not exists(select 1 from cim_erp_address a where t.customer_id=a.customer_id);
无敌小二傻 2016-06-27
  • 打赏
  • 举报
回复
典型的 merge into 的用法,存在则插入!
卖水果的net 2016-06-26
  • 打赏
  • 举报
回复
insert into cim_erp_address (customer_id,address_type,id_fragment,modify_date) 
-- values ((  -- 这个 values 不要

select t.customer_id from cim_customer t
 where t.customer_id not in (select a.customer_id from cim_erp_address a)),2,'N','2007-10-15 10:31:24');
程序猿zy 2016-06-26
  • 打赏
  • 举报
回复
INSERT INTO 语句 添加一个或多个记录至一个表。这叫作追加查询. 语法 多重记录追加查询INSERT INTO target [(field1[, field2[, ...]])][IN外部数据库] SELECT field1[, field2[, ...]] FROM tableexpression 单一记录追加查询: INSERT INTO target [(field1[, field2[, ...]])] VALUES (value1[, value2[, ...])

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧