嘉婾儌滇婔婾 1 启 0 䔇庖严婾㔗垄傸埇傖䫘庯庻嗘启䕘蓗寡嘉毷乕㔗潏傸橬婴䓉 SQL 嘉䌂傋bit(n) 启 bit varying(n) 認麯䔇 n 滇婔婻溼昘昄㔗
bit 䌂傋䔇昄扞媙釂庖䇞对陉阪庥 n 臘商庻嗘䘺底潡蔙阪婔底䔇昄扞鄘滇髍臇䔇㔗bit varying 䌂傋昄扞滇橔阪 n 䔇埻阪䌂傋敘阪䔇婾嚔赆拐䂺㔗喍婔婻澇橬阪庥䔇 bit 京昽庯 bit(1) 澇橬阪庥䔇 bit varying 懟攺滇澇橬阪庥鍊彽㔗
㔊濘懟㔏套悩潏傸滯䇞婄檪婔婻嘉婾唚蘸扵潊 bit(n) 闼幽垄䔇埿膹儖赆潻桺潡蔙婘埿膹臖阊镽䕘彄彔喘 n 嘉蔯婉嚔檕庺傂嘘髍臇㔗䌂嚚婄套悩潏傸滯䇞婄檪婔婻嘉婾昄唚蘸扵潊 bit varying(n) 套悩垄轙誺庖 n 嘉闼幽垄䔇埿膹儖赆潻桺㔗
臙埗蔄誗4.1.2.3诙埡橬噿嘉婾婩麟䔇臺濘媇敇㔗誻橬婔底嘉锂膏淉嘩严启嘉崇䊖庘昄埇䫘埗蓕誗9.6㔗
冋8-3. 嘪䫘嘉婾䌂傋
CREATE TABLE test (a BIT(3), b BIT VARYING(5)); INSERT INTO test VALUES (B'101', B'00'); INSERT INTO test VALUES (B'10', B'101'); ERROR: bit string length 2 does not match type bit(3) INSERT INTO test VALUES (B'10'::bit(3), B'101'); SELECT * FROM test; a | b -----+----- 101 | 00 100 | 101