Grokbase
Topics Posts Groups | in
x
[ help ]

Jon Collette (j...@etelos.com)

Profile | Posts (1)

User Information

Display Name:Jon Collette
Partial Email Address:j...@etelos.com
Posts:
1 total
1 in PostgreSQL - SQL

1 Most Recent Post

1) Jon Collette [SQL] Boolean without default declared
| +1 vote
If a column with a boolean datatype doesn't have a default value. What type of value is set if...
PostgreSQL - SQL
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
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.

            Table "public.users"
 Column |         Type          | Modifiers
--------+-----------------------+-----------
 id     | character varying(32) |
 email  | text                  |
 happy  | boolean               |
 money  | numeric               |


*select * from users;                *
 id | email  | happy |  money 
----+--------+-------+---------
 4  | me     |       | 1324.23
 4  | me     |       | 1324.23
 3  | as     |       |   123.2
 1  | afjssd | t     |       

*select * from users where happy;*
 id | email  | happy | money
----+--------+-------+-------
 1  | afjssd | t     |     

*select * from users where not happy;*
id | email | happy | money
----+-------+-------+-------
(0 rows)

*select * from users where happy = NULL;*
id | email | happy | money
----+-------+-------+-------
(0 rows)

*select * from users where happy = '';*
ERROR:  invalid input syntax for type boolean: ""


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

spacer
Profile | Posts (1)
Home > People > Jon Collette