Inherited tables and NOT NULL (pg 7.2.1)

From: "Luke Pascoe" <luke(dot)p(at)kmg(dot)co(dot)nz>
To: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Inherited tables and NOT NULL (pg 7.2.1)
Date: 2003-01-23 23:02:40
Message-ID: 01b101c2c333$881940e0$3200000a@K2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm playing around with inherited tables to see if they're suitable for a
task I'm about to begin.

I want to create 6 tables, all with the same columns except 1. They will
_always_ be this way, ie. any new column added will be added to all. Sounds
perfect for inherited tables right?

Well I was trying out adding a new column to my "Parent" table, I wanted a
not null, defaulted, integer column, so I did:

temp=> ALTER TABLE Parent ADD ddd INT;
ALTER
temp=> UPDATE Parent SET ddd = 0;
UPDATE 2
temp=> ALTER TABLE Parent ALTER COLUMN ddd SET DEFAULT 0;
ALTER
temp=> ALTER TABLE Parent ADD CONSTRAINT ddd_nn CHECK (ddd IS NOT NULL);
ERROR: AlterTableAddConstraint: rejected due to CHECK constraint ddd_nn

Why can't I add this check to the Parent table?

========================================
Luke Pascoe
Senior Developer / Systems administrator
KMG (NZ) Limited. http://www.kmg.co.nz
Mobile: (021) 303019
Email: luke(dot)p(at)kmg(dot)co(dot)nz
========================================

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2003-01-23 23:03:41 Re: I was spoiled by the MySQL timestamp field
Previous Message codeWarrior 2003-01-23 22:45:48 Re: Pg 7.3.1 & DBD::Pg 1.21