Re: [GENERAL] Table create time - Mailing list pgsql-general

From Achilleas Mantzios
Subject Re: [GENERAL] Table create time
Date
Msg-id a8dd8bd0-e44a-ca85-55f2-7f1e3b027b08@matrix.gatewaynet.com
Whole thread Raw
In response to Re: [GENERAL] Table create time  (Melvin Davidson <melvin6925@gmail.com>)
Responses Re: [GENERAL] Table create time  (Melvin Davidson <melvin6925@gmail.com>)
List pgsql-general
On 31/08/2017 18:20, Melvin Davidson wrote:
>you could just create an event trigger looking for CREATE TABLE as filter_value:

I have tried that. Unfortunately, I have been unable to extract the table name from the event because TG_TABLE_NAME is not
available during an event trigger, albeit perhaps I am missing something?
You need to use ddl_command_end event and then select from pg_event_trigger_ddl_commands() . Search for some example how to do this.
That being said, I still believe it is extra work that could easily be avoided and should be added to the postgresql catalogs simply to be
more feature competitive with  Oracle & SQL Server, as well as a boost to the PostgreSQL community.

On Thu, Aug 31, 2017 at 10:54 AM, Michael Paquier <michael.paquier@gmail.com> wrote:
On Thu, Aug 31, 2017 at 10:21 PM, Melvin Davidson <melvin6925@gmail.com> wrote:
> Wolfgang, as David said, a column in pg_class for the creation time of a table does not exist. I long ago requested that feature as it is
> in other DB's (Oracle & MS SQL Server), but the main reason that it was not done was that no one was interested in doing it.

Is there any need for a column in pg_class for that? You could just
create an event trigger looking for CREATE TABLE as filter_value:
https://www.postgresql.org/docs/9.6/static/sql-createeventtrigger.html
And then have this event trigger just save the timestamp value of
now() in a custom table with the name and/or OID of the relation
involved.
--
Michael



--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [GENERAL] Table create time
Next
From: Melvin Davidson
Date:
Subject: Re: [GENERAL] Table create time