title: What is the easiest way to make a column READONLY in Oracle?
body: <p>We have one of those weird cryptic data corruption bugs that pops up every few weeks and no one knows why.  So far, it appears that the primary key on a table is spontaneously changing, so other rows that point to it are now messed up.</p>
  
  <p>Though I'm still looking for the root cause of this (it's impossible to repro), I would like some sort of temporary hack to prevent a column value from ever changing.  Here's the table schema:</p>
  
  <pre><code>CREATE TABLE TPM_INITIATIVES  ( 
      INITIATIVEID    NUMBER NOT NULL,
      NAME            VARCHAR2(100) NOT NULL,
      ACTIVE          CHAR(1) NULL,
      SORTORDER       NUMBER NULL,
      SHORTNAME       VARCHAR2(100) NULL,
      PROJECTTYPEID   NUMBER NOT NULL,
      CONSTRAINT TPM_INITIATIVES_PK PRIMARY KEY(INITIATIVEID)
      NOT DEFERRABLE
       VALIDATE
  )
  </code></pre>
  
  <p>We of course need to be able to create new rows, but I want to prevent ANYTHING from changing <code>INITIATIVEID</code> ever, no matter what weird queries are being run.</p>
  
  <p>Some ideas I can think of:</p>
  
  <ul>
  <li>I'm not really familiar with table permissions on Oracle (I'm more
  of a Postgres guy), but can't you GRANT or DENY update rights on a
  certain column to all users?  Would this just affect updates, or
  INSERTS as well?  What would be the command the DENY updates to this column?</li>
  <li>Create some sort of trigger that runs on ROW UPDATE.  Can we
  detect if the <code>INITIATIVEID</code> is being changed, and if so, throw an
  exception or blow up in some way?</li>
  </ul>
  
  <p>At the very least, can we trap and/or log this event to see when it happens and what the query is that causes <code>INITIATIVEID</code> to change?</p>
  
  <p>Thanks!</p>