[sql] 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. Can anyone give me a sample SQL query for that?

Thank you!

This question is related to sql oracle

The answer is


Just add in the '0' in your select.

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

just select '0' as the value for the desired column


Put 0 as default in SQL or add 0 into your area of table