copying indexes and f.keys from a template table

From: Enrico Sirola <enrico(dot)sirola(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org General <pgsql-general(at)postgresql(dot)org>
Subject: copying indexes and f.keys from a template table
Date: 2007-06-20 10:57:55
Message-ID: 2B2C0810-C67D-4759-A79B-8EFE2559BF4E@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
I'm trying to build a set of plpgsql functions in order to ease
partitioning by date, let's say
one table per day for a total of 30 days.
I have plpgsql functions to create the partition tables (having a
date suffix) and to manage
a retention period, however I still need to solve a problem with
indexes/foreign keys.
The partition tables are inherited from a template table, and while
inheriting I loose
the information on indexes/keys. One possibility would be to write a
facility to execute
a set of ddl statements on all the partition tables using a template
(e.g. using a
placeholder for the table name) or maybe one could use the
information on Primary/foreign keys
and indexes present also in the system tables so I guess one should
be able to use it to build
the PK/FKs and indexes on the partition tables. Any advice?
Thanks in advance,

Enrico Sirola
enrico(dot)sirola(at)gmail(dot)com

Browse pgsql-general by date

  From Date Subject
Next Message Rhys Stewart 2007-06-20 12:25:03 Re: regexp searching in arrays not working?
Previous Message David Abrahams 2007-06-20 10:55:06 Need help with generic query