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
  • 4,314
  • 2
  • 23
  • 33
nunos
  • 20,479
  • 50
  • 119
  • 154

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,315
  • 1
  • 22
  • 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
  • 18,859
  • 7
  • 53
  • 79