Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL question re inserts
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
![]() |
![]() |