简体   繁体   English

Oracle 从选择插入到具有更多列的表中

[英]Oracle insert from select into table with more columns

I want to insert to a table from a select statement, however, there are 3 columns returned from the select statement and the table has 4 columns, I would like to add 0 for all rows in the extra column.我想从 select 语句插入到一个表中,但是,select 语句返回了 3 列,并且该表有 4 列,我想为额外列中的所有行添加 0。 Can anyone give me a sample SQL query for that?谁能给我一个示例 SQL 查询?

Thank you!谢谢!

Just add in the '0' in your select.只需在您的选择中添加“0”即可。

INSERT INTO table_name (a,b,c,d)
    SELECT
       other_table.a AS a,
       other_table.b AS b,
       other_table.c AS c,
       '0' AS d
    FROM other_table

在 SQL 中将 0 作为默认值或将 0 添加到您的表区域中

只需选择“0”作为所需列的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM