Inherited tables and NOT NULL (pg 7.2.1)

Поиск
Список
Период
Сортировка
От Luke Pascoe
Тема Inherited tables and NOT NULL (pg 7.2.1)
Дата
Msg-id 01b101c2c333$881940e0$3200000a@K2
обсуждение исходный текст
Ответы Re: Inherited tables and NOT NULL (pg 7.2.1)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Dennis Gearon
Дата:
Сообщение: Re: standard schemas for addresses, others?
Следующее
От: Joseph Shraibman
Дата:
Сообщение: Re: Optimizer too eager to choose full table scans