2

Sorry for this lame question, but I really am a database newbie:

I want to store the date when I create a certain field on the database. Is there any attribute I can add to that date field so that it cannot be modified? I just want the date field to have the date when a field is created on never want to edit it.

I am using PostgreSQL.

Thanks.

Stefan Collier
  • 3,688
  • 1
  • 23
  • 31
nunos
  • 19,269
  • 49
  • 116
  • 153

2 Answers2

2

There is no way to actually do this; however, if you want to make this occur you would perform a trigger on update for that specific table.field and throw a DBMS error. There might be a more elegant way to do this; but this is all I can think of to protect a specific value once it has been written.

Community
  • 1
  • 1
Suroot
  • 4,229
  • 1
  • 21
  • 28
  • 1
    so basically, what you are saying is to create the field with a DEFAULT for current_timestamp and never edit the field again right? – nunos Mar 27 '11 at 02:43
  • Well it could be a default value; but you could also set it on INSERT. Creating a trigger for ONLY update will ensure that the field will not be updated. – Suroot Mar 27 '11 at 02:44
1

I think PostgreSQL supports column level permissions. Check this : PostgreSQL 8.4 Feature List

Anuraj
  • 17,523
  • 7
  • 50
  • 77