From: | Luca Ferrari <fluca1978(at)infinito(dot)it> |
---|---|
To: | Romain Billon-Grand <billongrand(at)hotmail(dot)fr> |
Cc: | Forum postgres debutants <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Keeping track of updates/performances |
Date: | 2015-03-17 12:40:57 |
Message-ID: | CAKoxK+4c8fbLS9VKA47kuK_6ssDd99O3vFnu20Sfv1b0xrhZ0A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Ciao,
On Tue, Mar 17, 2015 at 9:06 AM, Romain Billon-Grand
<billongrand(at)hotmail(dot)fr> wrote:
> 1/ I have been looking for built in options in postgres but I guess I have
> to build it myself...?
> Of course if Postgres already does it I am very happy, and all of the
> following quetsions are useless but I did not find this in the
> documentation...
>
You can use current_user and 'now'::timestamp for instance to get the
actual time and user.
Place this in a trigger for insert/update and you made it.
> Or, even if it exists, maybe I would better get it back from some user table
> such as
> CREATE TABLE users (username TEXT, role TEXT, id_user..); ??
>
What is the aim? There is the catalog for tracking users and roles.
> for timestamps, I guess triggers would be the best way to do the job, but I
> would like to have the whole table updated automatically without having to
> include this in all my update quieries...
>
and triggers will do the magic update as you want, so what is the
problem with triggers?
>
> 3/ once such a table is built like this for example
> CREATE TABLE track (creation TIMESTAMP, last_modification TIMESTAMP,
> created_by TEXT, lastmodified_by TEXT)
>
> What would be the advantages and drawbacks of this :
> CREATE TABLE anytable(...) INHERITS (tracks)
> vs this: CREATE TABLE anytable (...) LIKE tracks?
inheritance means that the new table will share columns with the
parent, while like will copy the DDL for the table and the constraint.
You should have a look at the documentation:
http://www.postgresql.org/docs/current/static/sql-createtable.html
Luca
From | Date | Subject | |
---|---|---|---|
Next Message | Romain Billon-Grand | 2015-03-17 18:21:43 | Re: Keeping track of updates/performances |
Previous Message | Felipe Santos | 2015-03-17 12:18:11 | Re: Keeping track of updates/performances |