Adding audit trail fields and triggers to all tables

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Adding audit trail fields and triggers to all tables
Date: 2007-02-14 16:38:40
Message-ID: eqveip$1f7f$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to add the following fields to all tables to existing 8.1 database:

created timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,

createdby text DEFAULT CURRENT_USER,

updated timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,

updatedby text -- current_user who last updates this record

I need also to add triggers so that updated and updatedby fields ae
automatically set when record is changed.

Where to find script which implements this ?

Andrus.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message marcelo Cortez 2007-02-14 17:09:22 Re: PGSQL 8.2.3 Installation problem
Previous Message Peter Eisentraut 2007-02-14 16:28:26 Re: Advisory on possibly insecure security definer functions