Re: SQL Experts Only

From: Virag Saksena <vsaksena_at_us.oracle.com>
Date: 1996/08/08
Message-ID: <320A8E1F.53A_at_us.oracle.com>#1/1


This SQL Statement should do it ....

insert into table_b

       (IDENTIFIER_ID,FK_TABLE_A_ID)
select some_seq.nextval, a.identifier_id   from table_a a;

If you are populating additional columns from table_a into table_b you can include those in this statement.

Regards,

Virag


Virag Saksena                                         vsaksena_at_us.oracle.com
Senior Principal Consultant                                     415.506.5087
System Performance Group
Oracle Services

David & Kim Di Biaggio wrote:
>
> Ken Kennedy wrote:
> >
> > Here is my dilema...
> >
> > I have two tables in production that appear as shown below:
> >
> > SQL> desc TABLE_A
> > Name Null? Type
> > ------------------------------- -------- ----
> > IDENTIFIER_ID NOT NULL NUMBER
> > SOME_FIELD_1 VARCHAR2(20)
> > SOME_FIELD_2 NUMBER
> >
> > SQL> desc TABLE_B
> > Name Null? Type
> > ------------------------------- -------- ----
> > IDENTIFIER_ID NOT NULL NUMBER
> > FK_TABLE_A_ID NUMBER
> > SOME_OTHER_FIELD VARCHAR2(20)
> >
> > Currently, only TABLE_A is populated and TABLE_B is a new table. I need
> > to insert an entry in TABLE_B for each row in TABLE_A. If there are 30
> > rows in TABLE_A, I need to insert 30 rows in the new table. The
> > IDENTIFIER_ID is a sequence number (SOME_SEQ) and the FK_TABLE_A_ID is a
> > foreign key to TABLE_A.IDENTIFIER_ID.
> >
> > Can I do the update through SQL? I know I can make the update writing a
> > quick C++/ODBC application, but I'd rather just use SQL.
> >
> > Any help is greatly appreciated.
> >
> > Ken
>
> Try:
>
> insert into table_b
> select some_seq, identifier_id
> from table_a;

--
Received on Thu Aug 08 1996 - 00:00:00 CEST

Original text of this message