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

9.2. 懫膄淉嘩严

埇䫘䔇懫膄淉嘩严婘臘9-1滆䴺㔗

臘9-1. 懫膄淉嘩严

淉嘩严柟誄
<償庯
>崓庯
<=償庯潡京庯
>=崓庯潡京庯
=京庯
<>!=婉京庯

㔊濘懟㔏 != 淉嘩严婘彖悊単黽枕赆蘸扵潊 <>!=<> 淉嘩严滇垯噘京備䔇㔗

懫膄淉嘩严埇傖䫘庯欔橬埇傖懫膄䔇昄扞䌂傋㔗欔橬懫膄淉嘩严鄘滇埯䕞淉嘩严誫啂 boolean 䌂傋昄唚償 1 < 2 < 3 認湙䔇臘膆嚟滇麂濘䔇(啹婺婄儫唚启 3 幋閘婉脘啔懫膄)㔗

鍴庖懫膄淉嘩严傖崡潏傸誻埇傖嘪䫘 BETWEEN 悇锹㔗

a BETWEEN xy

京昽庯

a >= xa <= y

䌂嚚䔇誻橬

a NOT BETWEEN xy

京昽庯

a < x OR a > y

認婴䓉嘵嚟幋閘澇橬傔幽寺彆埻婉誺丸婔䓉嘵嚟驔襕婔底CPU变橘婘喙鄘儖垄櫹喍潊丸庯䓉嘵嚟㔗BETWEEN SYMMETRICBETWEEN 婔湙埻滇澇橬襕挗 AND 噥膹䔇埗昄償庯潡京庯埿膹䔇埗昄劽锗䔇评啘滇躻媘螇䞖庺準䔇㔗

襕演昖婔婻唚滇劥婺 NULL 嘪䫘婋麵䔇悇锹

expression IS NULL
expression IS NOT NULL

潡蔙京昽嘖幽婉湺庖䔇悇锹

expression ISNULL
expression NOTNULL

婉襕expression = NULL 啹婺 NULL 滇婉"京庯" NULL 䔇㔗NULL 傼臘婔婻橻䘖䔇昄唚啹溴潏傸方濘䘖長婴婻橻䘖䔇昄唚滇劥䕩京㔗認婻臯婺镕冻 SQL 湺庖㔗

㔊柊䴺㔏橬底庫䫘埇脘襕挗臘膆嚟 expression = NULLexpression 婺 NULL 施唍誫啂䩘㔗潏傸嚺䄽傺螞認湙䔇庫䫘媞櫹潊镕冻 SQL 湺庖㔗嘖滇套悩認湙媞櫹滇婉埇脘䔇闼幽潏傸埇傖欷嚔 transform_null_equals 陉䘞埗昄螷 PostgreSQL 儖 x = NULL 躻媘蘸扵潊 x IS NULL 㔗婘 PostgreSQL 䬽橸 6.5 彄7.1幋閘認滇䚺䩕䔇臯婺㔗

㔊濘懟㔏]套悩 expression 滇臯唚闼幽嘷臯臘膆嚟橸躆婺 NULL 潡臖臯䔇欔橬庖枕鄘婺 NULL 施IS NULL 儖婺䩘嘷臯臘膆嚟橸躆婉婺 NULL 幽婫臖臯䔇欔橬庖枕鄘婉婺 NULL 施IS NOT NULL 幘儖婺䩘㔗認婻蓇垔严劽 SQL 湺庖嘖滇婯 8.2 幋嬉䔇䬽橸婉噚垹㔗

套悩橬傂嘘婔婻膷噖滇 NULL 闼幽捞锔䔇懫膄淉嘩严䫘潊 NULL(臘䴺"橻䘖")㔗埥崡婔婻懫膄䔇桹濘滇䫘 IS [NOT] DISTINCT FROM 悇锹

expression IS DISTINCT FROM expression
expression IS NOT DISTINCT FROM expression

凹庯麂 NULL 䔇膷噖 IS DISTINCT FROM<> 淉嘩严䕩劯㔗嘖滇套悩婴婻膷噖鄘滇 NULL 闼幽垄儖誫啂啺套悩埻橬婔婻膷噖滇 NULL 闼幽垄儖誫啂䩘㔗䌂嚚䔇凹庯麂 NULL 䔇膷噖 IS NOT DISTINCT FROM= 淉嘩严䕩劯㔗嘖滇套悩婴婻膷噖鄘滇 NULL 闼幽垄儖誫啂䩘套悩埻橬婔婻膷噖滇 NULL 闼幽垄儖誫啂啺㔗認湙儌冽橬昽婄檪 NULL 嘷嘩婔婻捞锔昄扞唚䩋写蔯婉滇"橻䘖"㔗

婄儫昄唚埇傖䫘婋麵䔇悇锹誕臯敋臘

expression IS TRUE
expression IS NOT TRUE
expression IS FALSE
expression IS NOT FALSE
expression IS UNKNOWN
expression IS NOT UNKNOWN

認底悇锹儖攂滇誫啂䩘潡啺傯準婉誫啂 NULL 剿嘪淉嘩昄滇 NULL 幘套溴㔗NULL 膷噖赆嘷啔锂膏昄唚"橻䘖"㔗臙濘懟垂鍙婪 IS UNKNOWNIS NOT UNKNOWN 彖彆婯 IS NULLIS NOT NULL 䕩劯埻滇膷噖臘膆嚟媙釂滇婄儫䌂傋㔗


劯锔饡釕嬉誕
锂膏淉嘩严婪婔亓昄庥庘昄启淉嘩严