PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 28th, 2003, 10:28 AM
xeiro xeiro is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Jamaica
Posts: 2 xeiro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to xeiro Send a message via AIM to xeiro
Date of a database??

I was just wondering... does a database in postgres have some sort of date attribute attached to it? What I want to do is check the last time a database was modified... that is ... data added/removed from it. I'm running postgresql 7.2 on a Linux Box.

Does anyone know if this is possible?

Reply With Quote
  #2  
Old March 28th, 2003, 02:52 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
I suppose there are a couple ways:

1. Check the log. In most normal configurations, there is at least some information logged for each query. If you turn on more logging features you can even make it store the text of each query, so you know exactly what was done. (the logfile is usually in /usr/local/pgsql/data/serverlog)

2. File access time. The data in a database is stored in files. If you turn off the postgres daemon, and then examine the last access time of the files, you might be able to figure this out. Can't guarantee, though. For example, the postgres deamon itself does certain things in the background from time to time.

Perhaps if you spend more time in the documentation and mailling lists, you would find another way, but I don't know of any.
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #3  
Old March 28th, 2003, 07:49 PM
xeiro xeiro is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Jamaica
Posts: 2 xeiro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to xeiro Send a message via AIM to xeiro
Thanks rycamor ... was hoping there was a simpler solution such as an attribute in the pg_database system table or some other system table perhaps... that would be so cool.

I want to check the modification dates of about 70+ Databases to see when work was last done on them. Different users will work on them. So as superuser .... wanted to check when a database was last modified. If there was a date attribute in some sytem table and a corresponding database .... then I could just do a couple of select statments to see when they were last modified

*Sigh* :-)

Reply With Quote
  #4  
Old March 28th, 2003, 08:18 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
Yeah, that would be nice, but think of the overhead to update the system tables for each insert/update/delete.
__________________
FSBO (For Sale By Owner) Realty

Reply With Quote
  #5  
Old March 28th, 2003, 10:27 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
In general I agree with rod k. But, there are a couple things you might think about. First, I don't know whether you want to check for changes to the data in your DB, or for users creating changes in the structure, so #1 is regarding the data, and #2 regards structure.

1. Set up a special logging table. If you are familiar with PostgreSQL's RULE system, you would realize that on any table or view, you can create a rule (similar to a trigger, but more lightweight) which also executes whatever additional query you want. So, create a rule that saves some data in another table, whenever anyone does anything with the main table or tables you are concerned with.

2. Set up a rule on the appropriate system table. PostgreSQL is the most extensible DMBS in existence, IMHO. Almost everything about your database is availabe in the system tables, just like any regular data table. It should be possible, theoretically, to identify a few important system tables having to do with database structure, and set a rule on each, to log queries to a separate table. (disclaimer: I have not tested this, so I don't know what the results would be)

Again, rod k's warning about overhead applies.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Date of a database??

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap