Hi,

@Sergi

This is DB2's way too, but need grammars change in many others commands like:
 
    [CREATE | ALTER] TABLE  [ADD|ALTER] CONSTRAINTS ...

Referential Constaint:

 --+- [ NOT DEFERRABLE ] -----------------+-
   |                                      |
   +- DEFERRABLE INITIALLY-+- IMMEDIATE-+
                            |             |
                            +- DEFERRED  --+
*
Upon creation, a constraint* is given one of three characteristics:
    DEFERRABLE INITIALLY DEFERRED,
    DEFERRABLE INITIALLY IMMEDIATE,
    NOT DEFERRABLE.
The third class is always IMMEDIATE and is not affected by the SET CONSTRAINTS 
command.
The first two classes start every transaction in the indicated mode, but their 
behavior can be changed within a transaction by SET CONSTRAINTS.

@Rami,

> SET CHECKS_DEFERRED TRUE  for the lifetime of that connection.

I think that your proposition isn't enough, a finer granularity is needed 
because the constraint's subject is the CONSTRAINT and not the sentence .

In cases with circular references (like your initial sample) be able to setup 
IMMEDIATE for all sentence  in a transaction ,
make no sense because this will fail always and that is known at design time. 

> "Compatibility
> This command complies with the behavior defined in the SQL standard, except 
> for the limitation that, in PostgreSQL, it does not apply to NOT NULL and 
> CHECK constraints. Also, PostgreSQL checks non-deferrable uniqueness 
> constraints immediately, not at end
> of statement as the standard would suggest."

You are right, but this matter is mainly about REFERENTIAL constraints - 
nothing is perfect !

> Who would like to say in his tables definition:
> COLUMN INTEGER NOT NULL DEFERRABLE INITIALLY DEFERRED UNIQUE DEFERRABLE 
> INITIALLY IMMEDIATE PRIMARY KEY  NOT DEFERRABLE REFERENCES FOO(x) DEFERRABLE 
> INITIALLY DEFERRED ON UPDATE RESTRICT ON DELETE CASCADE
>

In the grammar if any nothing is specified defaults to  NOT DEFERRABLE, so you 
only need to specify deferred cases (that are exceptional cases).

regards,
Dario.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to