I am wondering if there is a way to show custom "values" in the output of a query purely for readability, similar to the AS statement for renaming column labels.

Seems unlikely but would be useful for cutting down a number of custom post-query formatting steps.


| type (varchar) | status (boolean) |
| A              | t                |
| B              | f                |


| type  | status |
| A     | true   |
| B     | false  |


| type  | status     |
| A     | collecting |
| B     | disabled   |

I am aware I could change the database to contain these values, but this is not possible in this case.



You can use a CASE WHEN clause to custom the output :

SELECT CASE WHEN status THEN 'true' 
            WHEN NOT status THEN 'false' 
            ELSE 'uknknown' 
       END AS status 
FROM mytable;

If you want to change the default output of PostgreSQL in order to output 'true' instead of 't', I'm pretty sure it is not possible.

| improve this answer | |
  • That's exactly what I was looking for. Thank you for your help. – CatsLoveJazz Jun 5 '15 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.