Skip site navigation (1) Skip section navigation (2)

Truncate table at a certain size.

From: Dana Huggard - Navarik <dhuggard(at)navarik(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Truncate table at a certain size.
Date: 2008-04-28 22:35:04
Message-ID: 1209422104.12712.12.camel@H-S12.internal.navarik.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hello,

What would be the best method to truncate a table once it reaches a
certain size.   

For instance, a table named log.  I can check the size of the log;

   db=# select pg_relation_size('log');
   pg_relation_size 
   ------------------
                 8192
   (1 row)


What I would like to do is 

If table log, is greater than xxxx bytes
   then truncate table log


Maybe I'll dump it to a flat file first, (yes, it should really be a
flat file to start with, and not in a db.)

Thank you.




Responses

pgsql-sql by date

Next:From: Tom LaneDate: 2008-04-28 23:14:58
Subject: Re: information_schema.referential_constraints permissions
Previous:From: Nacef LABIDIDate: 2008-04-28 22:33:44
Subject: currval of sequence "my_seq" is not yet defined in this session

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group