Link to home
Start Free TrialLog in
Avatar of thomaszhwang
thomaszhwangFlag for United States of America

asked on

Is there any difference between the following two statements in Oracle?

SELECT * INTO tableA FROM tableB;

INSERT INTO tableB SELECT * FROM tableA;

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thomaszhwang

ASKER

Oh really?  I didn't know that.  In Vertica, both work the same way.  I will also test this out tomorrow.  Thanks sdstuber.  You help me a lot! :)
INSERT INTO used when table exists, and SELECT INTO - when table does not exist

http://www.blackwasp.co.uk/SQLSelectInsert.aspx
Avatar of Sean Stuber
Sean Stuber

YZlat, that was covered already yesterday
@sdstuber, I think you are right.

@YZlat, I tried to SELECT INTO a non-existing table, but it still failed.  The following is my SQL.

SELECT col1, col2 INTO table2 FROM table1;
Thanks.
In pl/sql you could do

SELECT * BULK COLLECT INTO tableA FROM tableB;

if tableA is a collection, see the pl/sql guides in the oracle documentation for more info