SQL 滇嚺䌂傋臺蘔㔗幘儌滇臘懟婻昄扞鄘婯婔婻喿垔噽臯婺启䫘濘䔇昄扞䌂傋䕩噿蕫㔗PostgreSQL 橬婔婻埇欷匘䔇昄扞䌂傋係䂘臖係䂘懫噽垄 SQL 垂䯄敘噙锔䫘攓启䕕昂攓㔗啹蔯PostgreSQL 婺崓崔昄䌂傋蘸扵滇䫌锔䫘蓇彍準䞇䊖䔇蔯婉滇䫌婷閘䔇臘毵濘彖悊䔇認䓉啔濘嘪冖晙劽䌂傋臘膆嚟埻冖橬懟幬剿冪滇噽婺寙劆䫘潙垔幬䔇䌂傋幘套溴㔗
PostgreSQL 欆柟/彖悊単埻儖臉濘噄䘹彖蓼潊庫婻嘺橸䓉䌂昘昄㔕敞䗹昄㔕庖严婾㔕劉庖㔕噿髞庖㔗崓崔昄麂昄庖䌂傋饡噽臘冕婺庖严婾SQL 臺蘔䔇垔幬噕螩儖䌂傋劉弄滯婺庖严婾認婻橺彽赆 PostgreSQL 䫘庯媺臕彖悊単澪五溼䇞䔇桹劏誊臯㔗冋套婋麵昖臵
SELECT text 'Origin' AS "label", point '(0,0)' AS "value"; label | value --------+------- Origin | (0,0) (1 row)
橬婴婻桺橸婩麟䌂傋彖彆婺 text 启 point 㔗套悩澇橬婺庖严婾桺橸弄滯䌂傋臖桺橸噽赆彺哋寡潊婔婻拖橬庻嗘䷺閘䔇 unknown 䌂傋臖䌂傋儖婘劯麵柟誄䔇捔橘黽枕彖悊㔗
婘 PostgreSQL 彖悊単麯橬啕䓉嘺橸䔇 SQL 噄䘹驔襕䋸䆋䔇䌂傋蘸扵蓇彍
崔昄 PostgreSQL 䌂傋係䂘滇傺亏婘婔喖婄凯䔇庘昄婪䔇㔗庘昄脄䫘埇傖橬婔婻潡崔婻埗昄㔗啹婺 PostgreSQL 噕螩庘昄麉蘘欔傖庘昄劉躻躆幽婉嫇婔婄湺臖儖襕脄䫘䔇庘昄彖悊単媙釂湹扞庘昄柊冕䔇埗昄䌂傋锬拷溼䇞䔇庘昄㔗
PostgreSQL 噕螩婘臘膆嚟婪嘪䫘嬉䚔潡劯䚔(剘䕞)淉嘩严幘噕螩臘膆嚟喙鄘嘪䫘埯䕞淉嘩严(婴婻埗昄)㔗償庘昄婔湙淉嘩严幘埇傖赆麉蘘啹溴淉嘩严䔇锬拷幘启庘昄婔湙埡喿庯埗昄䌂傋㔗
INSERT 启 UPDATE 臺埖儖臘膆嚟䂷悩櫆噖臘婺㔗臺埖婺䔇臘膆嚟䌂傋媙釂启䕞湺庖枕䔇䌂傋婔躘潡蔙埇傖蘸扵婺婔躘㔗
啹婺蕫劽 SELECT 臺埖婺䔇欔橬昖臵䂷悩媙釂婘婔彖麯滆䴺庺準欔傖懟婻 SELECT 床埖婺䔇噄䘹䌂傋媙釂䕩庐对陉幽蘸扵潊婔喖䂘婔䌂傋㔗䌂嚚婄婔婻 CASE 悇锹䔇䂷悩臘膆嚟媙釂蘸扵潊䂘婔䔇䌂傋認湙 CASE 臘膆嚟躻躆嘩婺昘嘷橬婔䓉噾䘖膷庺䌂傋㔗劯湙䔇襕挗幘庻婘庯 ARRAY 悇锹傖埪 GREATEST
启 LEAST
庘昄婺㔗
係䂘臘 casts 庻嗘橬噿巻䓉昄扞䌂傋幋閘䔇蘸扵滇劽濘䔇傖埪套嘘欓臯認底蘸扵䔇媇敇㔗鵺崡䔇蘸扵埇傖䫌䫘潙锔誺 CREATE CAST 变傴嵂媹㔗認婻锔婩启垔幬婔䓉桄䔇昄扞䌂傋婔蕙垯潊㔗喙䘞䔇䌂傋蘸扵镖噾䂟䂟誺傫䂖䔇镘䊵庖啹溴橔喘婉襕寂敘櫹垄傸㔗
彖悊単婺誻橬婔婻抩䘵単䫘庯敘喘婄䯩敋 SQL 湺庖䌂傋䔇䇞彺䬹攓㔗彖悊単麯垔幬庖庹䓉䌂傋评䘘boolean, numeric, string, bitstring, datetime, timespan, geometric, network, user-defined(䫘潙垔幬)㔗鍴䫘潙垔幬䌂傋崡懟䓉䌂傋鄘橬婔䓉饡锬䌂傋䫘庯蓼喿䌂傋垔幬溓幬䔇閞鵻㔗凹庯䫘潙垔幬䔇䌂傋噽躻躆儌滇躻噌䔇饡锬䌂傋欔傖凹庯闼底劆晙婉橙䔇臘膆嚟(婘彖悊䂷悩婺橬崔䓉埇脘䔇臘膆嚟)套悩橬崔婻喙䘞䌂傋䔇施唍崓崔埇傖溼䇞彖悊嘖套悩橬崔婻䫘潙垔幬䌂傋埇锬彍嚔檕庺髍㔗
欔橬䌂傋蘸扵蓇彍鄘滇傺䆋婘婋麵庹婻嘺橸寘彍婪䔇
锊劆蘸扵喿婉脘橬喺攻䔇潡婉埇鵇蓕䔇膷庺㔗
䫘潙垔幬䌂傋啹婺彖悊単凹噽澇橬 鵇噽䘖臖婘䌂傋亓彆婺庫臖亓彆膄"醻"㔗婘晙劽䌂傋䔇臘膆嚟麯喙鄘䌂傋攂滇庫臖蘸扵潊䫘潙垔幬䌂傋(嘷䇽埻滇婘媙釂蘸扵䔇施唍)㔗
䫘潙垔幬䌂傋滇婉䕩噿䔇㔗䕞嬉PostgreSQL 鍴庖䫘庯喙鄘昄扞䌂傋䔇䇸傼乕抩䘵単启傖䯄橬庘昄婺嘺䇔䔇锊劆䌂傋噿係崡澇橬傂嘘埇䫘庯崇䊖䌂傋閘噿係䔇媇敇㔗
套悩婔婻昖臵婉驔襕锊劆䔇䌂傋蘸扵彖悊単潡欓臯単婉庫臖誕臯敘崔䔇鵺崡淉嘩㔗認儌滇臘傂嘘婔婻䌂傋对陉㔕湚嚟橙捄䔇昖臵婉庫臖婘彖悊単麯蔖蘹敘崔䔇施閘幘婉庫臖劏昖臵婺嚘噖傂嘘婉媙襕䔇锊劆䌂傋蘸扵脄䫘㔗埥崡套悩婔婻昖臵锔婩嘪䫘昊婻庘昄誕臯锊劆䌂傋蘸扵蔯䫘潙垔幬庖婔婻橬溼䇞埗昄䔇庘昄蓼麪単庫臖嘪䫘桄庘昄埡傼寘噽斓庘昄䔇锊劆淉嘩㔗