| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: truncate problem
kev <kevin.porter_at_fast.no> wrote in message news:3816E7CE.D4DDAD11_at_fast.no...
> I forgot to mention that I have followed the 'Action' instructions from
> the 'oerr ora 02266' statement:
>
> *Action: Before performing the above operations the table, disable the
> //          foreign key constraints in other tables. You can see what
> //          constraints are referencing a table by issuing the following
> //          command:
> //          SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam";
>
>
> but the above query returns an empty set of data.
This is not the currect way. Use the following statement to find out the correct referencing tables.
select owner, table_name, constraint_name from all_constraints
  where (r_owner, r_constraint_name) in
    (select owner, constraint_name
      from all_constraints where table_name='HEADLINE');
> kev wrote:
>
> > I've just tried to do a truncate on a table, but get this error:
> >
> > ORA-02266: unique/primary keys in table referenced by enabled foreign
> > keys
> >
> > The table was created like this:
> >
> > create table headline
> > (
> >         id number(10) primary key,
> >         headline varchar2(200),
> >         url varchar2(200),
> >         grabtime number(15),
> >         comments varchar2(200),
> >         lang number(4),
> >
> >         constraint fk_headline_lang
> >                 foreign key (lang)
> >                 references language (id)
> > );
> >
> > Is the constraint causing the problem? No row in the headline table has
> > any value in the lang column.
The ora-2266 error is not caused by the constraint of this table,
but the constraint of other table.
Since the headline table has a "child" table,
it can not be truncated when the foreign key is enabled.
Received on Thu Oct 28 1999 - 12:03:34 CDT
![]()  | 
![]()  |