Re: Partitions Table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



idris khanafi <idris.khanafi@xxxxxxxxx> 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

-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux