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

10.4. 唚庻嗘

襕某噖臘婺䔇昄唚幘湹扞婋麵䔇準黴蘸扵潊䕞湺彖䔇昄扞䌂傋㔗

唚庻嗘昄扞䌂傋蓼悊

  1. 昖欆婯䕞湺庖枕庖䇞䔇对陉㔗

  2. 臘五儖臘膆嚟䕘毖蘸扵潊䕞湺䌂傋㔗套悩噾䘖認婴䓉䌂傋幋閘庻婘婔婻噾濘喯䔇蘸扵庘昄闼幽䕘毖脄䫘臖蘸扵庘昄剿埇㔗套悩臘膆嚟滇婔婻橻䘖䌂傋桺橸臖桺橸庖严婾䔇喙垹儖庴䂍䕞湺䌂傋䔇膷噖蘸扵誺䘋㔗

  3. 演昖婔婋䩋䩋䕞湺䌂傋滇劥橬阪庥蘸扵㔗阪庥蘸扵滇婔婻傯昊䌂傋彄躻躆䔇蘸扵㔗套悩婘 pg_cast 臘麯麵欆彄婔婻闼幽婘庻嗘彄䕞湺庖枕幋嬉噽婘臘膆嚟婪庫䫘㔗認湙䔇蘸扵庘昄攂滇毖埖婔婻鵺崡䔇䌂傋婺 integer 䔇埗昄垄毖櫽䕞湺庖枕䔇弄滯阪庥(垂鍙婪滇噽 atttypmod 唚atttypmod 䔇蓼麪锟婉劯䔇昄扞䌂傋蔯婉劯)㔗蘸扵庘昄蘘蘼桘媹闼底阪庥䕩噿䔇臺幬懫套阪庥演昖潡蔙潻桺㔗

冋10-6. character 庻嗘䌂傋蘸扵

凹婔婻䕞湺彖垔幬婺 character(20) 䔇臺埖婋麵䔇臺埖䇞媺庻嗘唚䔇阪庥溼䇞

CREATE TABLE vv (v character(20));
INSERT INTO vv SELECT 'abc' || 'def';
SELECT v, length(v) FROM vv;

          v           | length
----------------------+--------
 abcdef               |     20
(1 row)

認麯䩘溼埏䫘䔇庋愙滇婴婻 unknown 桺橸䚺䩕蓼悊潊 text 認湙儌噕螩 || 淉嘩严蓼悊潊 text 誂毖㔗䇽劯淉嘩严䔇 text 䂷悩蘸扵潊 bpchar("䷺䍘准噙䔇庖严傋"character 䌂傋喙鄘劉䓄)傖对陉䕞湺庖枕䌂傋㔗婉誺啹婺䘖長 textbpchar 滇庯誕彽噚垹䔇認湙䔇蘸扵滇锊劆䔇幽婫垂鍙婪婉啔傂嘘庘昄脄䫘㔗橔劯婘係䂘臘麯欆彄阪庥蘸扵庘昄 bpchar(bpchar, integer) 幽婫庫䫘庯臖淉嘩严䔇䂷悩幽庻嗘庖枕阪㔗認婻䌂傋䕩噿䔇庘昄欓臯欔驔䔇阪庥演昖启鵺崡䔇䷺䍘准噙㔗


劯锔饡釕嬉誕
庘昄婪婔亓UNION, CASE 启䕩噿悇锹