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: Prohibit updating Primary Key?

Re: Prohibit updating Primary Key?

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/04/21
Message-ID: <8dq7ka$rtb$1@nnrp1.deja.com>#1/1

In article <38FFC46E.9CC64BFC_at_ev1.net>,
  dsscott_at_ev1.net wrote:
> Is it possible to prohibit a primary key from being updated on the
> server? In Designer when you create a primary key the dialog wizard
> asks if the primary key is updateable. Does Designer write code that
> some how prohibits the primary key from being updated if this property
> is set to no?
>
> Douglas Scott
>
>

you could write a trigger to enforce this:

create or replace trigger t_trigger
after update of x on t for each row
begin

    if ( :new.x <> :old.x ) then

        raise_application_error( -20001, 'cannot update primary key' );     end if;
end;
/

or, when granting update on this table, just grant update on all of the columns EXCEPT the primary key.... That won't totally prevent it as the owner can still do the update (and people with update any table) but normal users won't be able to update it.

--
Thomas Kyte                              tkyte_at_us.oracle.com
Oracle Service Industries
http://osi.oracle.com/~tkyte/index.html
--
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Apr 21 2000 - 00:00:00 CDT

Original text of this message

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