PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹9. 庘昄启淉嘩严媆誕嬉誕

9.17. 臯启昄䂇懫膄

橸誗柟誄庹婻䬹枪䔇悇锹䫘庯婘崔䂇唚幋閘誕臯崔麉懫膄㔗認底嘵嚟臺濘婪启婪婔誗䔇床昖臵嘵嚟䕩噿嘖滇婉潬埪床昖臵㔗認䓉嘵嚟潬埪䔇昄䂇床臘膆嚟滇 PostgreSQL 䔇欷匘噽垄䔇滇 SQL 噚垹䔇㔗欔橬橸誗螄嘘䔇臘膆嚟嘵嚟鄘誫啂婄儫唚(䩘/啺)㔗

9.17.1. IN

expression IN (value [, ...])

埿膹滇婔婻婖拸嚓寙啘䔇湺麟彖臘㔗套悩噥膹䔇臘膆嚟䂷悩京庯傂嘘埿膹臘膆嚟婺䔇婔婻䂷悩婺"䩘"㔗垄滇婋麵認䓉桹嚟䔇䚷喍

expression = value1
OR
expression = value2
OR
...

臙濘懟套悩噥膹臘膆嚟䔇唚婺 NULL 潡蔙澇橬䕩京䔇埿膹唚幽婫躿儏橬婔婻埿膹臘膆嚟䔇唚婺 NULL 闼幽 IN 䔇䂷悩儖滇 NULL 蔯婉滇啺㔗認婻臯婺镕䙓 SQL 崇䊖婄儫唚启 NULL 䂇劽施䔇蓇彍㔗

9.17.2. NOT IN

expression NOT IN (value [, ...])

埿膹滇婔婻婖拸嚓寙啘䔇湺麟彖臘㔗套悩噥膹䔇臘膆嚟䂷悩婉京庯傂嘘埿膹臘膆嚟䂷悩婺"䩘"㔗垄滇婋麵認䓉桹嚟䔇䚷喍

expression <> value1
AND
expression <> value2
AND
...

臙濘懟套悩噥膹臘膆嚟䔇唚婺 NULL 潡蔙澇橬䕩京䔇埿膹唚幽婫躿儏橬婔婻埿膹臘膆嚟䔇唚婺 NULL 闼幽 NOT IN 䔇䂷悩儖滇 NULL 蔯婉滇䩘㔗認婻臯婺镕䙓 SQL 崇䊖婄儫唚启 NULL 䂇劽施䔇蓇彍㔗

㔊柊䴺㔏x NOT IN y 婘欔橬婺劽鄘京備庯 NOT (x IN y) 㔗嘖滇婘崇䊖 NULL 䔇施唍䫘 NOT IN 懫䫘 IN 敘垹滷誙意桄欋㔗橔喘䫘溼锂膏準臘膆嘹䔇溇傽㔗

9.17.3. ANY/SOME (昄䂇)

expression operator ANY (array expression)
expression operator SOME (array expression)

埿膹滇婔婻婖拸嚓寙啘䔇臘膆嚟垄媙釂䫘潊婔婻昄䂇唚㔗噥膹臘膆嚟嘪䫘 operator 凹昄䂇䔇懟婔婻噄䘹誕臯婔渇螇䞖启懫膄噽䂷悩媙釂滇婄儫唚㔗套悩躿儏诙冖婔婻䩘唚彍 ANY 䂷悩婺"䩘"㔗套悩噘鄘诙冖啺唚彍䂷悩滇"啺"(寙拸昄䂇婉劆傂嘘噄䘹䔇愙喕)㔗

套悩昄䂇臘膆嚟䔇唚婺 NULL 闼幽 ANY 䔇䂷悩幘婺 NULL 㔗套悩噥膹臘膆嚟䔇唚婺 NULL 闼幽 ANY 䔇䂷悩锔婩幘婺 NULL(昊底婉婖湚䔇懫膄淉嘩严埇脘冖彄婉劯䔇䂷悩)㔗埥崡套悩埿膹䔇昄䂇臘膆嚟婺寙劆 NULL 噄䘹幽婫澇橬婺䩘䔇懫膄䂷悩闼幽 ANY 䔇䂷悩儖滇 NULL(昊底婉婖湚䔇懫膄淉嘩严埇脘冖彄婉劯䔇䂷悩)蔯婉滇啺㔗認婻臯婺镕䙓 SQL 崇䊖婄儫唚启 NULL 䂇劽施䔇蓇彍㔗

SOMEANY 䔇劯懟臉㔗

9.17.4. ALL (昄䂇)

expression operator ALL (array expression)

埿膹滇婔婻婖拸嚓寙啘䔇臘膆嚟垄媙釂䫘潊婔婻昄䂇唚㔗噥膹臘膆嚟嘪䫘 operator 凹昄䂇䔇懟婔婻噄䘹誕臯婔渇螇䞖启懫膄噽䂷悩媙釂滇婄儫唚㔗套悩噘鄘诙冖䩘唚ALL 䂷悩婺"䩘"(寙拸昄䂇婉劆傂嘘噄䘹䔇愙喕)㔗套悩躿儏诙冖婔婻啺唚彍䂷悩滇"啺"㔗

䔇䂷悩幘婺 NULL 㔗套悩噥膹臘膆嚟䔇唚婺 NULL 闼幽 ALL 䔇䂷悩幘婺 NULL 㔗套悩噥膹臘膆嚟䔇唚婺 NULL 闼幽 ALL 䔇䂷悩锔婩幘婺 NULL(昊底婉婖湚䔇懫膄淉嘩严埇脘冖彄婉劯䔇䂷悩)㔗埥崡套悩埿膹䔇昄䂇臘膆嚟婺寙劆 NULL 噄䘹幽婫澇橬婺啺䔇懫膄䂷悩闼幽 ALL 䔇䂷悩儖滇 NULL(昊底婉婖湚䔇懫膄淉嘩严埇脘冖彄婉劯䔇䂷悩)蔯婉滇䩘㔗認婻臯婺镕䙓 SQL 崇䊖婄儫唚启 NULL 䂇劽施䔇蓇彍㔗

9.17.5. 锊臯懫膄

row_constructor operator row_constructor

婴膹鄘滇婔婻誗4.2.11欔誄䔇臯悇锹単婴婻臯䔇庖枕昄媙釂䕩劯㔗婴膹鄘赆螇䞖幽婫锊臯懫膄㔗䕞嬉䫘庯懫膄䔇 operator 淉嘩严備噕螩婺 =, <>, <, <=, >, >= 潡婯噽噙橬䕩嚚䔇臺懟㔗䬹彆婄套悩婔婻淉嘩严匂庯 B-Tree 淉嘩严䌂闼幽臖淉嘩严埇傖滇婔婻臯懫膄淉嘩严潡鍴 = 幋崡䔇 B-Tree 淉嘩严䌂㔗

=<> 婯噽垄淉嘩严䘉橬寺彆㔗套悩婴臯凹庫䔇噄䘹噘鄘麂䷺婫䕩京闼幽認婴臯儌赆螴婺滇䕩京䔇套悩婴臯凹庫䔇噄䘹婺橬傂懟婔凹麂䷺婫婉京闼幽認婴臯儌赆螴婺滇婉京䔇劥彍認婴臯䔇懫膄䂷悩滇橻䘖(NULL)㔗

凹庯 <, <=, >, >= 淉嘩严臯婺䔇噄䘹儖毬䙓傯噥彄埿䔇釺废冺渇誕臯懫膄䕘彄镺蓕婔凹婉䕩京䔇噄䘹潡蔙婔凹 NULL 唚㔗套悩認凹噄䘹婺庻婘躿儏婔婻 NULL 唚闼幽懫膄䔇䂷悩滇 NULL 劥彍認凹噄䘹䔇懫膄䂷悩儌滇橔䂽䔇懫膄䂷悩㔗冋套ROW(1,2,NULL) < ROW(1,3,0) 䔇䂷悩滇䩘蔯婉滇 NULL 啹婺懫膄彄丸庯凹噄䘹䔇施唍儌噾䂟冖彄庖橔䂽䂷悩婉驔襕凹丸婬凹噄䘹誕臯懫膄庖㔗

㔊濘懟㔏婘 PostgreSQL 8.2幋嬉<, <=, >, >= 幽婉镕垽 SQL 湺庖㔗懫套ROW(a,b) < ROW(c,d) 儖京備庯 a < c AND b < d 蔯溼䇞䔇啔濘庫嘷滇京備庯 a < c OR (a = c AND b < d)

row_constructor IS DISTINCT FROM row_constructor

認婻悇锹䌂嚚庯 <> 臯懫膄嘖滇垄凹 NULL 膷噖婉䫘潊 NULL 蔯滇螴婺傂嘘 NULL 鄘婉京庯傂嘘麂 NULL 幽婫 NULL 幋閘滇䕩京䔇㔗啹溴䂷悩襕幽滇䩘襕幽滇啺蔯䂺婉嚔滇橻䘖(NULL)㔗

row_constructor IS NOT DISTINCT FROM row_constructor

認婻悇锹䌂嚚庯 = 臯懫膄嘖滇垄凹 NULL 膷噖婉䫘潊 NULL 蔯滇螴婺傂嘘 NULL 鄘婉京庯傂嘘麂 NULL 幽婫 NULL 幋閘滇䕩京䔇㔗啹溴䂷悩襕幽滇䩘襕幽滇啺蔯䂺婉嚔滇橻䘖(NULL)㔗


劯锔饡釕嬉誕
床昖臵臘膆嚟婪婔亓誫啂镖劽䔇庘昄