Oracle 中 如果想把A表中的数据插入到B表中,通过外键,如何插入?
1个回答
展开全部
字段匹配不,总不能字符插到数字里嘛!
字段匹配的前提下,INSERT INTO B [此处填写,选择插入所需字段] SELECT [此处填写A表需要插到B表的字段] FROM A WHERE 后面加插入条件
范例:INSERT INTO Future
SELECT Substring(a.sDeptNO,1,1)+'处',Sum(a.nFutureSaleAmount)
FROM Future a,tDept b
WHERE a.sDeptNO = b.sDeptNO GROUP BY Substring(a.sDeptNO,1,1)
字段匹配的前提下,INSERT INTO B [此处填写,选择插入所需字段] SELECT [此处填写A表需要插到B表的字段] FROM A WHERE 后面加插入条件
范例:INSERT INTO Future
SELECT Substring(a.sDeptNO,1,1)+'处',Sum(a.nFutureSaleAmount)
FROM Future a,tDept b
WHERE a.sDeptNO = b.sDeptNO GROUP BY Substring(a.sDeptNO,1,1)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询