Re: best way to reference tables

From: "TJ O'Donnell" <tjo(at)acm(dot)org>
To: <dev(at)archonet(dot)com>
Cc: <tjo(at)acm(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: best way to reference tables
Date: 2005-08-09 18:48:18
Message-ID: 2256.209.223.166.104.1123613298.squirrel@www.gnova.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> TJ O'Donnell wrote:
>> I have many different tables that I want to keep track of.
>> So, I thought of a master table with those table names in it.
>> But, to maintain this (suppose a table changes
>> its name, gets dropped) I want to have some kind of referential
>> integrity - the way foreign keys and constraints do.
>> What could I use that would disallow inserting a name into
>> the master table unless another table by that name already exists? And what could ensure that
>> a table would not be renamed or dropped unless the master table is changed?
>
> You can write your own triggers that would stop you from adding a non-existent table to your
> master-table. You can't fire triggers on changes to system tables though, so you can't stop
> someone adding a table.
>
> In any case, you presumably want to track ALTER TABLE ADD COLUMN too so you'll need something a
> little smarter.
>
> Have you considered "pg_dump --schema-only" along with suitable
> version-control software (CVS/Subversion/Arch etc)? Or are you trying to track something
> specific?
>
> --
> Richard Huxton
> Archonet Ltd

My tables are a subset of all the tables - I'm not trying to keep track of everything!
So, I think I'll create a schema for the tables I need to keep track of, and create
some procedures to properly create/modify tables therein. I don't need to
keep track of all the innards of each table - ADD COLUMN, etc.

I guess what I'm asking is: Is there a better way to keep track of a table once
it's registered in my master table than just to put its name in my master table?
Some system oid type thing that stays fixed in spite of renames or other
tables mods?

TJ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2005-08-09 19:19:56 Re: Testing of MVCC
Previous Message Chris Travers 2005-08-09 18:42:46 Re: Poll on your LAPP Preferences