Re: Boolean without default declared - Mailing list pgsql-sql

From Richard Broersma Jr
Subject Re: Boolean without default declared
Date
Msg-id 775216.56005.qm@web31807.mail.mud.yahoo.com
Whole thread Raw
In response to Boolean without default declared  (Jon Collette <jon@etelos.com>)
List pgsql-sql
--- Jon Collette <jon@etelos.com> wrote:

> If a column with a boolean datatype doesn't have a default value.  What 
> type of value is set if nothing is inserted into that column?  Here is 
> my test table and the queries I have tried.  I can't seem to be able to 
> select the rows where happy has no value.
> 
> *select * from users where happy = '';*
> ERROR:  invalid input syntax for type boolean: ""

Databases have three value logic in it expressions.

is the expression true,
is the expression false,
is the expreassion unknown i.e. null.

SELECT * FROM users WHERE happy IS NULL;

UPDATE users SET happy = false WHERE happy IS NULL;

ALTER TABLE USER ALTER COLUMN happy SET NOT NULL;

Regards,
Richard Broersma Jr.


pgsql-sql by date:

Previous
From: Jon Collette
Date:
Subject: Boolean without default declared
Next
From: Richard Broersma Jr
Date:
Subject: Re: Boolean without default declared