Difference between INSERT INTO and INSERT ALL INTO

Posted by emily soto on Stack Overflow See other posts from Stack Overflow or by emily soto
Published on 2014-06-01T03:14:14Z Indexed on 2014/06/01 3:25 UTC
Read the original article Hit count: 111

Filed under:
|

While I was inserting some records in table i found that..

INSERT INTO T_CANDYBAR_DATA   
  SELECT CONSUMER_ID,CANDYBAR_NAME,SURVEY_YEAR,GENDER,1 AS STAT_TYPE,OVERALL_RATING 
  FROM CANDYBAR_CONSUMPTION_DATA
  UNION
  SELECT CONSUMER_ID,CANDYBAR_NAME,SURVEY_YEAR,GENDER,2 AS STAT_TYPE,NUMBER_BARS_CONSUMED 
  FROM CANDYBAR_CONSUMPTION_DATA;

79 rows inserted.

INSERT ALL
INTO t_candybar_data VALUES (consumer_id,candybar_name,survey_year,gender,1,overall_rating)
INTO t_candybar_data VALUES (consumer_id,candybar_name,survey_year,gender,2,number_bars_consumed)
SELECT  * FROM candybar_consumption_data

86 rows inserted.

I have read somewhere that INSERT ALL INTO automatically unions then why those difference is showing.

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle