aspose file tools*
The moose likes JDBC and the fly likes new table creation with data from different tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "new table creation with data from different tables" Watch "new table creation with data from different tables" New topic
Author

new table creation with data from different tables

raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
Hi All,

I am using oracle 9i as my database.

I am in need to create a new table(Bill) by copying some of required columns in older 'table A'. this was done and all the existing data was copied from "tableA" to "bill" table.

how ever now anorther column from "tableB" needs to be copied in to my "Bill" table.

i tried to with alter command but was not useful.

kindly let me how to copy all the data of certain column in table to the new table.

Reagrds,
raj chopra
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272

Whats the relation between your Bill table and table2. Some more information, would help me understand better.


Ashwin Sridhar
SCJP | SCWCD | OCA
raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
Hi Ashwin,

Thanks for reply.

"tableb" has these columns
org_id,
org_name,
org_ein,

"bill" table has below columns
org_id,
mem_id,
mem_name

all the org_id's in "tableb " are present in "bill"table. now i want to copy the org_name to bill table

Ashwin Sridhar wrote:Whats the relation between your Bill table and table2. Some more information, would help me understand better.
raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
HI,

i tried below query


select o.org_name
into bill from tableb o,bill b
where b.org_id = o.org_id


got error as "missing keyword"
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

This does not seem to be ORM related so moving this to the JDBC forum for you.


[How To Ask Questions][Read before you PM me]
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

what you want is an update with subselect statement.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

use the alter command to add the column, then an update to insert the data.
raj chopra
Ranch Hand

Joined: Apr 09, 2012
Posts: 60
Hi Wendy,
Wendy Gibbons wrote:what you want is an update with subselect statement.


thanks for reply the problem was solved. iused the alter command to add the new column and later on used the update query to copy all the needed data.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new table creation with data from different tables