Actually i am migrating my ms sql server into postgresql 9.3 and we were using int data type to store 1 and 0 for boolean values but in postgresql9.3 it is not possible. what di
if the column if of the boolean type then cast it to integer to compare to integer:
select the_boolean_column::int = 1;
to insert a boolean value as smallint cast it to integer fisrt
insert into t (integer_column) values (boolean_value::int::smallint)
to make the boolean_column always return integer create a view
create view v as
select boolean_column::int as integer_column
from t
When you query a boolean column it does not return 't'
or 'f'
. It returns a boolean value, true or false or null. The string representation of the value is up to the client, hence the 't'
.