Inherited tables and NOT NULL (pg 7.2.1) - Mailing list pgsql-general

From Luke Pascoe
Subject Inherited tables and NOT NULL (pg 7.2.1)
Date
Msg-id 01b101c2c333$881940e0$3200000a@K2
Whole thread Raw
Responses Re: Inherited tables and NOT NULL (pg 7.2.1)
List 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.p@kmg.co.nz
========================================



pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: standard schemas for addresses, others?
Next
From: Joseph Shraibman
Date:
Subject: Re: Optimizer too eager to choose full table scans