Search code examples
sqloracledata-integrity

SQL row modification constraint


I have a table, containing log entries. Is it possible to impose on it a constraint, restricting all modifications of rows, but still allowing addition and deletion of rows? For example if I have:

ID| Time |     Issue      | Result
------------------------------------
3   10:30  heating broke    repaired

It should be impossible to change id, time, issue or result, but it should be possible to create new rows or to delete the row.

I am using Oracle.

Many thanks!


Solution

  • Check the documentation...

    CREATE TRIGGER No_Updates_To_Table_X
    BEFORE UPDATE ON Table_X
    ....
    

    Or with permissions:

    REVOKE UPDATE ON XXXX FROM YYYY ....