Re: Help - Integrity Constraint / RTFM?

From: Rip McManus <rip_mcmanus_at_ccmail.turner.com>
Date: 1996/11/30
Message-ID: <01bbdef0$449bd040$2365a69d_at_rips_home_pc.turner.com>#1/1


I assume the question is because the foreign keys are new columns. You can add new columns via ALTER TABLE, e.g.,

ALTER TABLE table_name ADD
(new_fkey datatype NULL);

Populate the new column as appropriate, then

ALTER TABLE table_name MODIFY
(new_fkey NOT NULL);

Then add your indexes and/or constraints as you would normally. Of course, this will add the new columns to the end of the table, which can be a problem for any number of reasons. If it's a problem in your case, you may wish to take a different approach:

CREATE TABLE new_temp_table AS
SELECT select_clause_with_old_and_new_columns;

This would be followed by a DROP of your old table, a RENAME of your new_temp_table to table_name, and recreation of all old and new indexes and constraints.

I share your opinion on the availability of hard-copy documentation, especially for Oracle, and especially given the incredibly poor organization of most of the Oracle manuals available.

David J. Roth <droth_at_sii.com> wrote in article <01bbdc59$a54fefa0$8b0ebe9b_at_droth.sii.com>...
> Hard copy manuals are getting harder and harder to find.
> I don't always have ready access to a CD-ROM.
> --
> David J Roth
> (My own opinions)
>
> BozoBlaster <granaman_at_mail.phonet.com> wrote in article
> <57gcm2$lj6_at_iorich.phonet.com>...
> > In article <00001a1b+000095e2_at_msn.com>, tnade_at_msn.com (Toni Nadeau)
 wrote:
> > >I'm Sure this is an easy one for everybody - BUT -
> > >How can I add foreign keys to tables that have already been created?
> > >I'm using PO7,SQLPlus.
> > >Any hellp would be appreciated - Thanks
> > >
> > >tnade_at_msn.com
> >
> > alter table TABLE_NAME add ...
> >
> > Doesn't anyone RTFM anymore? It has got to be much easier than
 posting!
> >
> >
>
Received on Sat Nov 30 1996 - 00:00:00 CET

Original text of this message