Rogério Grando escreveu:
> Mas com essa solução fiquei com uma duvida, fiz os testes com a
> contraint (a)DEFERRABLE INITIALLY DEFERRED e (b)INITIALLY DEFERRED, nos
> dois modos funcionou, fui ler a documentação e ai que fique na duvida.
> Pelo que eu entendi a opção (a) ficou redundante a opção (b), não
> entendi a diferença entre as duas.
> 
Sim, mas isso está no padrão SQL. DEFERRABLE diz se um gatilho pode ser
postergável e INITIALLY [ DEFERRED | IMMEDIATE ] diz quando o gatilho será
disparado. INITIALLY DEFERRED implica em DEFERRABLE; INITIALLY IMEDIATE
implica em NOT DEFERRABLE.

Vide especificação:

<constraint name definition> ::= CONSTRAINT <constraint name>

<constraint attributes> ::=
       <constraint check time> [ [ NOT ] DEFERRABLE ]
     | [ NOT ] DEFERRABLE [ <constraint check time> ]

<constraint check time> ::=   INITIALLY DEFERRED
     | INITIALLY IMMEDIATE


Syntax Rules

1) If a <constraint name definition> is contained in a <schema def-
   inition>, and if the <constraint name> contains a <schema name>,
   then that <schema name> shall be the same as the specified or
   implicit <schema name> of the containing <schema definition>.

2) The <qualified identifier> of <constraint name> shall be differ-
   ent from the <qualified identifier> of the <constraint name> of
   any other constraint defined in the same schema.

3) If <constraint check time> is not specified, then INITIALLY
   IMMEDIATE is implicit.

         4) Case:

   a) If INITIALLY DEFERRED is specified, then:

     i) NOT DEFERRABLE shall not be specified.

    ii) If DEFERRABLE is not specified, then DEFERRABLE is im-
                 plicit.

   b) If INITIALLY IMMEDIATE is specified or implicit and nei-
      ther DEFERRABLE nor NOT DEFERRABLE is specified, then NOT
      DEFERRABLE is implicit.


-- 
  Euler Taveira de Oliveira
  http://www.timbira.com/
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a