Oracle Insert from Select into Table with More Columns

Oracle insert from select into table with more columns

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

SQL INSERT STATEMENT, ONLY TWO VALUES INTO A TABLE WHICH HAS MANY COLUMNS

Your syntax is incorrect. I believe you want:

INSERT INTO your_table_name (your_column_name, your_id ) 
(select your_column_name, 'abc' as your_id from another_table);

oracle select few columns from first table and insert (seq.nextval for one column + already selected columns) into second table

Your insert statement should have the column-names in the table. Then you should select the values from appropriate sequence and table.

INSERT INTO PRODUCT2 (PRD_ID, PRD_NAME) 
SELECT PRODUCT_SEQ.NEXTVAL, PRD_NAME FROM PRODUCT1


Related Topics



Leave a reply



Submit