Обсуждение: how to check the creation date of a postgres database?

Поиск
Список
Период
Сортировка

how to check the creation date of a postgres database?

От
Jessica Richard
Дата:
\l and  \l+ show only the database name, owner and description.
select * from pg_database does not have date info, either.

I would like to know when each of my databases were created.

Thanks,
Jessica


Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.

Re: how to check the creation date of a postgres database?

От
Chris Mair
Дата:
> \l and  \l+ show only the database name, owner and description.
> select * from pg_database does not have date info, either.
>
> I would like to know when each of my databases were created.

The only solution I can think of is querying
select oid, datname from pg_database;
and then look up the timestamps of the corresponding directories
in $PGDATA/base.

Bye, Chris.


--

Chris Mair
http://www.1006.org


Re: how to check the creation date of a postgres

От
"Tomeh, Husam"
Дата:
 
I don't believe it's stored in the database. The closer you can get is to check the date/timestamp of PG_VERSION file or possibly any file that may have an earlier date/timestamp, under your database base subdirectory ($PGDATA/base/your_database_oid/). For instance, for a database with OID of 34332 :
 
ls -lt  $PGDATA/base/34332/PG*

-rw-------  1 postgres postgres 4 Aug 24 10:41 PG_VERSION
 
(Note that the PG_VERSION file in your $PGDATA data directory signifies when the Postgres cluster was created, not a specific database)
 
--
  Husam
 

From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Jessica Richard
Sent: Wednesday, September 20, 2006 8:45 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] how to check the creation date of a postgres database?

\l and  \l+ show only the database name, owner and description.
select * from pg_database does not have date info, either.

I would like to know when each of my databases were created.

Thanks,
Jessica


Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.

**********************************************************************
This message contains confidential information intended only for the use of the addressee(s) named above and may contain information that is legally privileged.  If you are not the addressee, or the person responsible for delivering it to the addressee, you are hereby notified that reading, disseminating, distributing or copying this message is strictly prohibited.  If you have received this message by mistake, please immediately notify us by replying to the message and delete the original message immediately thereafter.

Thank you.

                                                                                                                         FADLD Tag
**********************************************************************

Re: how to check the creation date of a postgres database?

От
Jessica Richard
Дата:
It didn't seem to work....

I just checked one $PGDATA/base directory,  they all have today's time stamp (9/20/06)  around 6:00 am this morning, that was when my daily database dump cron job was running...

thanks anyway



Chris Mair <chrisnospam@1006.org> wrote:

> \l and \l+ show only the database name, owner and description.
> select * from pg_database does not have date info, either.
>
> I would like to know when each of my databases were created.

The only solution I can think of is querying
select oid, datname from pg_database;
and then look up the timestamps of the corresponding directories
in $PGDATA/base.

Bye, Chris.


--

Chris Mair
http://www.1006.org



How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

Re: how to check the creation date of a postgres database?

От
Jessica Richard
Дата:
Thanks, but I still can't get the database creation date....


% cat PG_VERSION
8.1

16% ls -lt PG*
-rw-------    1 postgres users          4 Jun 22 10:34 PG_VERSION

This date was the date that the Postgres server was upgraded to 8.1 and the timestamp of this file is same under each of all database directories....




"Tomeh, Husam" <htomeh@firstam.com> wrote:
 
I don't believe it's stored in the database. The closer you can get is to check the date/timestamp of PG_VERSION file or possibly any file that may have an earlier date/timestamp, under your database base subdirectory ($PGDATA/base/your_database_oid/). For instance, for a database with OID of 34332 :
 
ls -lt  $PGDATA/base/34332/PG*

-rw-------  1 postgres postgres 4 Aug 24 10:41 PG_VERSION
 
(Note that the PG_VERSION file in your $PGDATA data directory signifies when the Postgres cluster was created, not a specific database)
 
--
  Husam
 

From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Jessica Richard
Sent: Wednesday, September 20, 2006 8:45 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] how to check the creation date of a postgres database?

\l and  \l+ show only the database name, owner and description.
select * from pg_database does not have date info, either.

I would like to know when each of my databases were created.

Thanks,
Jessica

Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.
**********************************************************************
This message contains confidential information intended only for the use of the addressee(s) named above and may contain information that is legally privileged.  If you are not the addressee, or the person responsible for delivering it to the addressee, you are hereby notified that reading, disseminating, distributing or copying this message is strictly prohibited.  If you have received this message by mistake, please immediately notify us by replying to the message and delete the original message immediately thereafter.
Thank you.
                                                                                                                         FADLD Tag
**********************************************************************


Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail.

Re: how to check the creation date of a postgres database?

От
Chris Mair
Дата:
> It didn't seem to work....
>
> I just checked one $PGDATA/base directory,  they all have today's time
> stamp (9/20/06)  around 6:00 am this morning, that was when my daily
> database dump cron job was running...

You can check the PG_VERSION file under each database's directory as
Husam said...


Bye, Chris.




Re: how to check the creation date of a postgres database?

От
Chris Mair
Дата:
> Thanks, but I still can't get the database creation date....
>
>
> % cat PG_VERSION
> 8.1
>
> 16% ls -lt PG*
> -rw-------    1 postgres users          4 Jun 22 10:34 PG_VERSION
>
> This date was the date that the Postgres server was upgraded to 8.1
> and the timestamp of this file is same under each of all database
> directories....

Ah, then the information was lost when you upgraded :/

Backups of the data files prior to the upgrade?

Bye, Chris.




Re: how to check the creation date of a postgres database?

От
Jim Nasby
Дата:
On Sep 20, 2006, at 11:45 AM, Jessica Richard wrote:
> \l and  \l+ show only the database name, owner and description.
> select * from pg_database does not have date info, either.
>
> I would like to know when each of my databases were created.

You're not the first person to ask for this, but it's still pretty
unclear what the use-case for that info is (and without a decent use-
case, it's pretty unlikely that this info will get stored).

So... why is it you want to know this?
--
Jim Nasby                                    jimn@enterprisedb.com
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)




--
Jim Nasby                                    jimn@enterprisedb.com
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)



Re: how to check the creation date of a postgres database?

От
Tom Lane
Дата:
Jim Nasby <jim@nasby.net> writes:
> On Sep 20, 2006, at 11:45 AM, Jessica Richard wrote:
>> I would like to know when each of my databases were created.

> You're not the first person to ask for this, but it's still pretty
> unclear what the use-case for that info is (and without a decent use-
> case, it's pretty unlikely that this info will get stored).

If we did store it, it would presumably reflect the time of issuance of
CREATE DATABASE, which would mean it wouldn't survive a dump and reload
anyway (as the OP seems to be wishing for).

            regards, tom lane

Re: how to check the creation date of a postgres database?

От
"Jim C. Nasby"
Дата:
Please include the list in your replies.

On Fri, Sep 22, 2006 at 09:04:08AM -0700, Jessica Richard wrote:
> Thanks for your reply.
>
> It is for database documentation.

Is it really that important to know when a database was created?

I'm doubtful that anyone in the community will get excited enough to
make a patch based just on that use case; though if you were to create
one it might get accepted.

> Jim Nasby <jim@nasby.net> wrote: On Sep 20, 2006, at 11:45 AM, Jessica Richard wrote:
> > \l and  \l+ show only the database name, owner and description.
> > select * from pg_database does not have date info, either.
> >
> > I would like to know when each of my databases were created.
>
> You're not the first person to ask for this, but it's still pretty
> unclear what the use-case for that info is (and without a decent use-
> case, it's pretty unlikely that this info will get stored).
>
> So... why is it you want to know this?
--
Jim C. Nasby, Database Architect                   jim@nasby.net
512.569.9461 (cell)                         http://jim.nasby.net

Re: how to check the creation date of a postgres database?

От
"Jim C. Nasby"
Дата:
On Fri, Sep 22, 2006 at 10:30:55AM -0400, Tom Lane wrote:
> Jim Nasby <jim@nasby.net> writes:
> > On Sep 20, 2006, at 11:45 AM, Jessica Richard wrote:
> >> I would like to know when each of my databases were created.
>
> > You're not the first person to ask for this, but it's still pretty
> > unclear what the use-case for that info is (and without a decent use-
> > case, it's pretty unlikely that this info will get stored).
>
> If we did store it, it would presumably reflect the time of issuance of
> CREATE DATABASE, which would mean it wouldn't survive a dump and reload
> anyway (as the OP seems to be wishing for).

Well, that case could be handled as well, it's just a SMOC. But as I
mentioned, it's unlikely an existing developer will get excited about
any of this.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)

Re: how to check the creation date of a postgres database?

От
Scott Marlowe
Дата:
On Fri, 2006-09-22 at 11:17, Jim C. Nasby wrote:
> On Fri, Sep 22, 2006 at 10:30:55AM -0400, Tom Lane wrote:
> > Jim Nasby <jim@nasby.net> writes:
> > > On Sep 20, 2006, at 11:45 AM, Jessica Richard wrote:
> > >> I would like to know when each of my databases were created.
> >
> > > You're not the first person to ask for this, but it's still pretty
> > > unclear what the use-case for that info is (and without a decent use-
> > > case, it's pretty unlikely that this info will get stored).
> >
> > If we did store it, it would presumably reflect the time of issuance of
> > CREATE DATABASE, which would mean it wouldn't survive a dump and reload
> > anyway (as the OP seems to be wishing for).
>
> Well, that case could be handled as well, it's just a SMOC. But as I
> mentioned, it's unlikely an existing developer will get excited about
> any of this.

How about a default database comment on creation if the user doesn't set
one, of "database created 2006-09-21 12:34:56"

Re: how to check the creation date of a postgres database?

От
"Jim C. Nasby"
Дата:
On Fri, Sep 22, 2006 at 11:30:55AM -0500, Scott Marlowe wrote:
> On Fri, 2006-09-22 at 11:17, Jim C. Nasby wrote:
> > On Fri, Sep 22, 2006 at 10:30:55AM -0400, Tom Lane wrote:
> > > Jim Nasby <jim@nasby.net> writes:
> > > > On Sep 20, 2006, at 11:45 AM, Jessica Richard wrote:
> > > >> I would like to know when each of my databases were created.
> > >
> > > > You're not the first person to ask for this, but it's still pretty
> > > > unclear what the use-case for that info is (and without a decent use-
> > > > case, it's pretty unlikely that this info will get stored).
> > >
> > > If we did store it, it would presumably reflect the time of issuance of
> > > CREATE DATABASE, which would mean it wouldn't survive a dump and reload
> > > anyway (as the OP seems to be wishing for).
> >
> > Well, that case could be handled as well, it's just a SMOC. But as I
> > mentioned, it's unlikely an existing developer will get excited about
> > any of this.
>
> How about a default database comment on creation if the user doesn't set
> one, of "database created 2006-09-21 12:34:56"

If we had catalog triggers, one could do that automagically...
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)