Oracle insert from select into table with more columns

SqlOracle

Sql Problem Overview


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!

Sql Solutions


Solution 1 - Sql

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

Solution 2 - Sql

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

Solution 3 - Sql

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlan HanView Question on Stackoverflow
Solution 1 - SqlMatt DodgeView Answer on Stackoverflow
Solution 2 - SqlAndrew View Answer on Stackoverflow
Solution 3 - SqlOtávio DécioView Answer on Stackoverflow