[英]Insert into Oracle sql developer
I want to ad column by using subquery.我想通过使用子查询来广告列。
Insert into Table_name
values (1, 'a', 'b', sysdate, sysdate + 120, 'c',
(Select number from other_table where column_name = 'x'), 2);
Error:错误:
ORA-01427: single-row subquery returns more than one row.
ORA-01427: 单行子查询返回多行。
How can I solve it?我该如何解决?
I think you want to use an INSERT INTO ... SELECT
here.我想你想在这里使用
INSERT INTO ... SELECT
。 Note that generally you should always specify the target columns.请注意,通常您应该始终指定目标列。
INSERT INTO Table_name (c1, c2, c3, c4, c5, c6, c7, c8)
SELECT 1, 'a', 'b', sysdate, sysdate + 120, 'c', number, 2
FROM other_table
WHERE column_name = 'x';
you need to force a single row你需要强制单行
note the extra "ROWNUM" below注意下面额外的“ROWNUM”
something like:就像是:
Insert into Table_name values(1,'a','b',sysdate,sysdate + 120,'c',(Select number from other_table where column_name = 'x' and ROWNUM = 1),2);
see: https://blogs.oracle.com/connect/post/on-rownum-and-limiting-results请参阅: https ://blogs.oracle.com/connect/post/on-rownum-and-limiting-results
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.