Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

new table creation with data from different tables

 
raj chopra
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats the relation between your Bill table and table2. Some more information, would help me understand better.
 
raj chopra
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This does not seem to be ORM related so moving this to the JDBC forum for you.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you want is an update with subselect statement.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the alter command to add the column, then an update to insert the data.
 
raj chopra
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic