Urgent:Help Needed to copy table data

View: New views
2 Messages — Rating Filter:   Alert me  

Urgent:Help Needed to copy table data

by MilindK007 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys can any one please help me for modifying below mentioned sql script so that i can run it in derby database.
create table abc as select * from bcd where name='ABC'
Please help...

Re: Urgent:Help Needed to copy table data

by Sylvain Leroux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Bad news: there's a current (as of version 10.5) limitation of CREATE ... SELECT
in Derby that only allows one to create the /structure/ of the table, but not to
insert the data in the same statement:
CREATE TABLE abc AS SELECT * FROM bcd WITH NO DATA
                                       ^^^^^^^^^^^^
(the WHERE clause is useless since we are not copying any row)


Good news: there is an INSERT ... SELECT statement that does the job
INSERT INTO abc SELECT * FROM bcd WHERE NAME='ABC'


As a conclusion, you will need both statements.

Ref:
http://db.apache.org/derby/docs/10.5/ref/rrefsqlj24513.html
http://db.apache.org/derby/docs/10.5/ref/rrefsqlj40774.html


I hope this helps,
Sylvain

MilindK007 a écrit :
>
> Hi guys can any one please help me for modifying below mentioned sql script
> so that i can run it in derby database.
> create table abc as select * from bcd where name='ABC'
> Please help...


--
sylvain@...
http://www.chicoree.fr