维 姜 wrote:
jw=# CREATE TABLE base ( CHECK (tableoid = 'base'::regclass) );
CREATE TABLE
jw=# \d base
Table "public.base"
Column | Type | Modifiers
--------+------+-----------
Check constraints:
"base_tableoid_check" CHECK (tableoid = 'base'::regclass::oid)
jw=# INSERT INTO base DEFAULT VALUES ;
ERROR: new row for relation "base" violates check constraint
"base_tableoid_check"
jw=#
The CHECK tests the tuple that is being inserted, which doesn't include
tableoid. I'm not sure if this counts as a bug or not.
You might be able to do this with a trigger function (although I'm not
clear what you're trying to do).
--
Richard Huxton
Archonet Ltd
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq