Re: Resolving of reference/foreign keys
| От | Fredrik Wendt |
|---|---|
| Тема | Re: Resolving of reference/foreign keys |
| Дата | |
| Msg-id | 3C97D84B.4090607@linux.se обсуждение исходный текст |
| Ответ на | Resolving of reference/foreign keys ("Oliver Friedrich" <oliver@familie-friedrich.de>) |
| Ответы |
Re: Resolving of reference/foreign keys
|
| Список | pgsql-jdbc |
Thomas O'Dowd wrote:
> [...]
> I've set ON DELETE to NO ACTION which means that if you delete a row
> from table a which is a FK in table b, the delete will fail unless you
> also delete the row in table b. I believe this is what you're looking
> for.
>
> You don't need to write any special code then to test or count
> references etc. Postgresql does it all for you. Check out the
> docs for more info.
Just a quick one: This deletion, must it be done in (1) one statement,
or can the delete operation be approved if (2) multiple delete
statements are issued within a transaction?
(1) DELETE FROM A, B WHERE B.table_A_ID = A.ID AND bla1 bla2
(2) BEGIN WORK
DELETE FROM A WHERE bla1
DELETE FROM B WHERE bla2
COMMIT
Are the above examples just rubbish, i.e. there are never any actual
cases where (2) can not be written as (1)?
/
Fredrik Wendt
В списке pgsql-jdbc по дате отправления: