Oracle查询一个表的数据插入到另一个表

  • 将一个表的字段数据插入到另一个表的字段数据中
	/** sys_guid 随机id */
	insert into t_A (shouruid,userid,username,userdeptid,userdeptname)
		select sys_guid(),userid,username,deptcode,deptname from t_B 
  • 多个表的多个字段,插入同一个表的多个字段
		insert into t_A (shouruid,userid,username,userdeptid,userdeptname)
		select sys_guid(),B.userid,B.username,C.deptcode,C.deptname
		from t_B B, t_Bmx C 
		where B.Bcode= C.Bcode  and B.scbj = '0' and 
		B.mxcode  not in (select procode from t_A where ywlx = 'ABC' and scbj = '0')

你可能感兴趣的:(常用小技巧,sql语句)