Search Postgresql Archives

Re: PRIMARY KEY on a *group* of columns imply that each column is

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

 



Marco Colombo wrote:
That is, given a variable A, you can always write a boolean expression
that evaluates True or False to test if A is _equal_ to None/undef/NULL
(in C):

And of course you can do this in SQL as well.

('a', NULL) is neither the same _nor different_ from ('a', 2).

Uh, I'm not sure what you mean by "the same"; but certainly ('a',NULL) is distinct from ('a',2).

The result of comparison is NULL, no matter how you're testing it:

Unless you're testing with the IS DISTINCT FROM operator.



fli=# select ('a',NULL) IS DISTINCT FROM ('a',2);
 ?column?
----------
 t
(1 row)

marco=# select ('a', 2) = ('a', NULL);
 ?column?
----------

(1 row)

marco=# select ('a', 2) <> ('a', NULL);
 ?column?
----------

(1 row)


fli=# select ('a',NULL) IS DISTINCT FROM ('a',NULL);
 ?column?
----------
 f
(1 row)


That's why NULLs are not allowed in primary keys...

But in general I agree with most of the rest of what you said.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux