From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | idris khanafi <idris(dot)khanafi(at)detik(dot)com> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: Partitions Table |
Date: | 2009-08-27 14:36:59 |
Message-ID: | 3366.1251383819@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
idris khanafi <idris(dot)khanafi(at)detik(dot)com> writes:
> i want to create partitions table :
> *create table advertisements_otomotif (CHECK (select * from
> advertisements where category_id in (select id from categories where
> name='Otomotif'))) INHERITS (advertisements)
> *
This is completely confused. I'm not sure what you are trying to
accomplish, but you've got at least three problems here:
1. Sub-selects used in expressions need to have their own set of
parentheses, ie you'd need something more like CHECK ((select ...))
to get past that syntax error.
2. The sub-select doesn't appear to return boolean, which is what
the CHECK would require.
3. Sub-selects aren't permitted in CHECK constraints, because they
would almost certainly do the wrong thing --- CHECKs are only checked
when a row in the current table is inserted or updated. So for example
modification or deletion of a row in the other table might make the
check expression no longer true, but the system wouldn't notice.
I think you might be trying to re-invent foreign keys, but without
an explanation of what it is you hope to accomplish, it's hard to
be sure.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | freedomyug@gmail.com | 2009-08-28 07:07:57 | [Commercial] Immediate Opening for PostgreSQL DBA at Efficient Frontier, Chennai |
Previous Message | Marc Mamin | 2009-08-27 12:23:58 | GRANT SELECT ON DATABASE |