patternsqlModerate
Why 't' and 'f' instead of TRUE and FALSE
Viewed 0 times
whytrueinsteadfalseand
Problem
Why does PostgreSQL return 't' and 'f' instead of TRUE and FALSE?
The documentation itself advises us to use TRUE and FALSE when inserting boolean values or making comparisons, but returns a different set of values when selecting the value from the database.
Is there a reason for this behavior? Have the PostgreSQL commmunity ever tried to change that?
The documentation itself advises us to use TRUE and FALSE when inserting boolean values or making comparisons, but returns a different set of values when selecting the value from the database.
CREATE TABLE test1 (a boolean, b text);
INSERT INTO test1 VALUES (TRUE, 'sic est');
INSERT INTO test1 VALUES (FALSE, 'non est');
SELECT * FROM test1;
a | b
---+---------
t | sic est
f | non estIs there a reason for this behavior? Have the PostgreSQL commmunity ever tried to change that?
Solution
PostgreSQL does not return these instead of boolean values. It is some clients (for example,
I guess the reason for showing
Note: I am in no way affiliated to DbVis Software.
psql and pgAdminIII) which represents TRUE with t and FALSE with f - try the same query in another client and you will see something else. See, for example, what DBVisualizer gives you:I guess the reason for showing
t and f is simply sparing space in a command-line client that lacks horizontal scrolling abilities.Note: I am in no way affiliated to DbVis Software.
Context
StackExchange Database Administrators Q#115234, answer score: 17
Revisions (0)
No revisions yet.