Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL question re inserts

Re: PL/SQL question re inserts

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Wed, 27 Aug 2003 12:08:14 -0700
Message-ID: <3F4D019D.FC5856B7@exxesolutions.com>


John Leslie wrote:

> Not sure if this is the correct forum for this question, but here
> goes.
>
> I want create a new row in a table which is identical to an existing
> row except for the key value.
>
> Is there an easy way to do this using the Insert statement, rather
> than reading and storeing the original record and then specifying each
> value for the insert statement?
>
> JL

INSERT INTO <table_name>
SELECT <new_key>, field1, field2, field3 FROM <table_name>
WHERE rownum = ....;

But be aware that if your system allows this your database is not normalized and your primary key is a meaningless surrogate.

--
Daniel Morgan
http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp
http://www.outreach.washington.edu/extinfo/certprog/aoa/aoa_main.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Wed Aug 27 2003 - 14:08:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US