Can somebody help me. I am trying to insert
Insert into dbc.xxx (a,b,c) values (select * from abc,null,null).
I want this query to get inserted into table not the value which we get after executing it.
Kindly help ASAP
"not the value which we get after executing it"
What do you mean with this?
You are mixing two different systax types of the insert stement.
you can use insert into tab values (val1,val2, ... valx);
for single row inserts
or insert into tab select col1, ..., colx from tabsource;
for insert selects.
Check the manuals!
Encapsulate the SQL query in the commas and treat it as a string...
Insert into dbc.xxx (a,b,c) values ('select * from abc',null,null)
it might give error if the table abc contains morethan one column/three columns,
and the query can be
insert into dbc.xxx(a,b,c) select * from abc; --if abc contains 3 column
insert into dbc.xxx(a,b,c) select a,null,null from abc; --if abc contains 1 column
Can someone tell me the advantage of using insert select into the empty table. Whether its I/o wise useful or CPU wise useful?
Thanks for your valuable comments.
In my case i am going to add two new columns into the huge table of 200 million rows. So i am planning to rename the existing table and create a table with new structure the use insert select to load the table. In this case which one will be affected I/O or CPU?