Re: Populating or Creating a Table from Another using SQL

From: SKurosky <skurosky_at_aol.com>
Date: 2000/02/25
Message-ID: <20000225144906.17866.00001937_at_ng-cn1.aol.com>#1/1


>COURTNEY WROTE:

 Have a table, Usage, that I would like to populate from another table,
>RetardedUsage. RetardedUsage has several columns but I would only like to
>include two in the Usage table. How would I go about doing this using SQL?
>
>SELECT Caid, Pairs FROM RetardedUsage WHERE Caid = 20 and Pairs < 600;
>
>I would like the results from that query to populate the new table, Usage,
>which has already been create and contains the two columns Caid and Pairs.
>
>Then I would like to query RetardedUsage again and append the results to the
>end of Usage. This code will be ran from within an Oracle Forms 4.5 trigger
>by the way...
>
>Please also copy a message to my email cwright_at_tdc-group.com
>
>Thanks,
>Courtney
>
>
>Hi Courtney,
If the USAGE table has already been created then you can issue an INSERT:

INSERT INTO Usage(caid,pairs)
SELECT caid,pairs
FROM RetardedUsage
WHERE caid=20 and

             pairs < 600;

>You could have done the whole thing at the time you created the new table by
Issuing;
CREATE TABLE Usage AS
SELECT caid, pairs
FROM RetardedUsage
WHERE caid=20 and

             pairs<600;

>HtH

Sandy

>Oh, can't issue DDL(such as CREATE) statement directly.Have to use DBMS_SQL
Built-In.

>
Received on Fri Feb 25 2000 - 00:00:00 CET

Original text of this message