PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹10. 䌂傋蘸扵媆誕嬉誕

10.1. 楗誄

SQL 滇嚺䌂傋臺蘔㔗幘儌滇臘懟婻昄扞鄘婯婔婻喿垔噽臯婺启䫘濘䔇昄扞䌂傋䕩噿蕫㔗PostgreSQL 橬婔婻埇欷匘䔇昄扞䌂傋係䂘臖係䂘懫噽垄 SQL 垂䯄敘噙锔䫘攓启䕕昂攓㔗啹蔯PostgreSQL 婺崓崔昄䌂傋蘸扵滇䫌锔䫘蓇彍準䞇䊖䔇蔯婉滇䫌婷閘䔇臘毵濘彖悊䔇認䓉啔濘嘪冖晙劽䌂傋臘膆嚟埻冖橬懟幬剿冪滇噽婺寙劆䫘潙垔幬䔇䌂傋幘套溴㔗

PostgreSQL 欆柟/彖悊単埻儖臉濘噄䘹彖蓼潊庫婻嘺橸䓉䌂昘昄㔕敞䗹昄㔕庖严婾㔕劉庖㔕噿髞庖㔗崓崔昄麂昄庖䌂傋饡噽臘冕婺庖严婾SQL 臺蘔䔇垔幬噕螩儖䌂傋劉弄滯婺庖严婾認婻橺彽赆 PostgreSQL 䫘庯媺臕彖悊単澪五溼䇞䔇桹劏誊臯㔗冋套婋麵昖臵

SELECT text 'Origin' AS "label", point '(0,0)' AS "value";

 label  | value
--------+-------
 Origin | (0,0)
(1 row)

橬婴婻桺橸婩麟䌂傋彖彆婺 textpoint 㔗套悩澇橬婺庖严婾桺橸弄滯䌂傋臖桺橸噽赆彺哋寡潊婔婻拖橬庻嗘䷺閘䔇 unknown 䌂傋臖䌂傋儖婘劯麵柟誄䔇捔橘黽枕彖悊㔗

婘 PostgreSQL 彖悊単麯橬啕䓉嘺橸䔇 SQL 噄䘹驔襕䋸䆋䔇䌂傋蘸扵蓇彍

庘昄脄䫘

崔昄 PostgreSQL 䌂傋係䂘滇傺亏婘婔喖婄凯䔇庘昄婪䔇㔗庘昄脄䫘埇傖橬婔婻潡崔婻埗昄㔗啹婺 PostgreSQL 噕螩庘昄麉蘘欔傖庘昄劉躻躆幽婉嫇婔婄湺臖儖襕脄䫘䔇庘昄彖悊単媙釂湹扞庘昄柊冕䔇埗昄䌂傋锬拷溼䇞䔇庘昄㔗

淉嘩严

PostgreSQL 噕螩婘臘膆嚟婪嘪䫘嬉䚔潡劯䚔(剘䕞)淉嘩严幘噕螩臘膆嚟喙鄘嘪䫘埯䕞淉嘩严(婴婻埗昄)㔗償庘昄婔湙淉嘩严幘埇傖赆麉蘘啹溴淉嘩严䔇锬拷幘启庘昄婔湙埡喿庯埗昄䌂傋㔗

唚庻嗘

INSERTUPDATE 臺埖儖臘膆嚟䂷悩櫆噖臘婺㔗臺埖婺䔇臘膆嚟䌂傋媙釂启䕞湺庖枕䔇䌂傋婔躘潡蔙埇傖蘸扵婺婔躘㔗

UNION, CASE 启䕩噿悇锹

啹婺蕫劽 SELECT 臺埖婺䔇欔橬昖臵䂷悩媙釂婘婔彖麯滆䴺庺準欔傖懟婻 SELECT 床埖婺䔇噄䘹䌂傋媙釂䕩庐对陉幽蘸扵潊婔喖䂘婔䌂傋㔗䌂嚚婄婔婻 CASE 悇锹䔇䂷悩臘膆嚟媙釂蘸扵潊䂘婔䔇䌂傋認湙 CASE 臘膆嚟躻躆嘩婺昘嘷橬婔䓉噾䘖膷庺䌂傋㔗劯湙䔇襕挗幘庻婘庯 ARRAY 悇锹傖埪 GREATESTLEAST 庘昄婺㔗

係䂘臘 casts 庻嗘橬噿巻䓉昄扞䌂傋幋閘䔇蘸扵滇劽濘䔇傖埪套嘘欓臯認底蘸扵䔇媇敇㔗鵺崡䔇蘸扵埇傖䫌䫘潙锔誺 CREATE CAST 变傴嵂媹㔗認婻锔婩启垔幬婔䓉桄䔇昄扞䌂傋婔蕙垯潊㔗喙䘞䔇䌂傋蘸扵镖噾䂟䂟誺傫䂖䔇镘䊵庖啹溴橔喘婉襕寂敘櫹垄傸㔗

彖悊単婺誻橬婔婻抩䘵単䫘庯敘喘婄䯩敋 SQL 湺庖䌂傋䔇䇞彺䬹攓㔗彖悊単麯垔幬庖庹䓉䌂傋评䘘boolean, numeric, string, bitstring, datetime, timespan, geometric, network, user-defined(䫘潙垔幬)㔗鍴䫘潙垔幬䌂傋崡懟䓉䌂傋鄘橬婔䓉饡锬䌂傋䫘庯蓼喿䌂傋垔幬溓幬䔇閞鵻㔗凹庯䫘潙垔幬䔇䌂傋噽躻躆儌滇躻噌䔇饡锬䌂傋欔傖凹庯闼底劆晙婉橙䔇臘膆嚟(婘彖悊䂷悩婺橬崔䓉埇脘䔇臘膆嚟)套悩橬崔婻喙䘞䌂傋䔇施唍崓崔埇傖溼䇞彖悊嘖套悩橬崔婻䫘潙垔幬䌂傋埇锬彍嚔檕庺髍㔗

欔橬䌂傋蘸扵蓇彍鄘滇傺䆋婘婋麵庹婻嘺橸寘彍婪䔇


劯锔饡釕嬉誕
䌂傋蘸扵婪婔亓淉嘩严