Como excluir pai sem ter que excluir filho.

Firebird

17/07/2003

POR FAVOR...
COMO POSSO EXCLUIR EM UM BANCO DE DADOS RELACIONAL DO INTERBASE UM REGISTRO PAI SEM TER QUE EXCLUIR TODOS OS REGISTROS FILHOS?

DESDE JÁ, OBRIGADO...


Hugo_sergio

Hugo_sergio

Curtidas 0

Respostas

Afarias

Afarias

17/07/2003

Deixa ver se entendi: Vc quer excluir o registro ´PAI´ e automaticamente *todos* os registros ´FILHO´ associados. Certo??

Basta usar integridade referencial, com CONSTRAINTS ou TRIGGERS, ex:


alter table TABELA_FILHO add constraint FK_FILHO_PAI (campo_pai)
references TABELA_PAI on delete cascade;

a opção ON DELETE CASCADE garante q excluindo-se o PAI todos os FILHOS são automaticamente excluidos!


T+


GOSTEI 0
POSTAR