Thread: character datatype explaination sought
I am testing Idempiere and have run across this in an example: character(1) DEFAULT 'Y'::bpchar NOT NULL, How does this differ from character(1) DEFAULT 'Y' NOT NULL, -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail Unencrypted messages have no legal claim to privacy Do NOT open attachments nor follow links sent by e-Mail James B. Byrne mailto:ByrneJB@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
"James B. Byrne" <byrnejb@harte-lyne.ca> writes: > I am testing Idempiere and have run across this in an example: > character(1) DEFAULT 'Y'::bpchar NOT NULL, > How does this differ from > character(1) DEFAULT 'Y' NOT NULL, It doesn't. The former is just written with an explicit cast, which the latter lacks, but the end result will be the same because the parser will coerce the DEFAULT expression to the column's type anyway. (It helps to know that for reasons lost in the depths of time, Postgres' internal name for the char(N) type is "bpchar".) regards, tom lane
On Thu, 2020-10-15 at 10:07 -0400, James B. Byrne wrote: > I am testing Idempiere and have run across this in an example: > > character(1) DEFAULT 'Y'::bpchar NOT NULL, > > How does this differ from > > character(1) DEFAULT 'Y' NOT NULL, It is the same, only in the first version the type cast is explicit. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com
On 10/15/20 7:07 AM, James B. Byrne wrote: > I am testing Idempiere and have run across this in an example: > > character(1) DEFAULT 'Y'::bpchar NOT NULL, > > How does this differ from > > character(1) DEFAULT 'Y' NOT NULL, It doesn't. From here: https://www.postgresql.org/docs/current/typeconv-query.html "... bpchar (“blank-padded char”, the internal name of the character data type) ..." > > > -- Adrian Klaver adrian.klaver@aklaver.com