Re: Boolean without default declared

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Boolean without default declared
Дата
Msg-id 775216.56005.qm@web31807.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Boolean without default declared  (Jon Collette <jon@etelos.com>)
Список 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 по дате отправления:

Предыдущее
От: Jon Collette
Дата:
Сообщение: Boolean without default declared
Следующее
От: Richard Broersma Jr
Дата:
Сообщение: Re: Boolean without default declared