pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed'' != NULL in PostGres???
4+ messages / 4 participants
[nested] [flat]
* '' != NULL in PostGres???
@ 1998-09-23 17:41 Neil Harkins <nharkins@well.com>
1998-09-23 18:10 ` Re: [SQL] '' != NULL in PostGres??? Brook Milligan <brook@trillium.NMSU.Edu>
0 siblings, 1 reply; 4+ messages in thread
From: Neil Harkins @ 1998-09-23 17:41 UTC (permalink / raw)
To: pgsql-sql
Hello. I am experimenting with Postgresql-6.3.2 on a RedHat 5.1 DEC Alpha:
nuacct=> create table users (
nuacct-> recno int,
nuacct-> custid int unique,
nuacct-> username char(14) not null,
nuacct-> service int
nuacct-> );
NOTICE: CREATE TABLE/UNIQUE will create implicit index users_custid_key
for table users
CREATE
nuacct=> insert into users values
nuacct-> ( 0, 0, '', 0 );
INSERT 18241 1
??? Shouldn't that have failed, generating an error ???
nuacct=> select * from users where username is null;
recno|custid|username|service
-----+------+--------+-------
(0 rows)
nuacct=> select * from users where username = '';
recno|custid| username|service
-----+------+--------------+-------
0| 0| | 0
(1 row)
nuacct=> \d users
Table = users
+----------------------------------+------------------------------+------+
| Field | Type |Length|
+----------------------------------+------------------------------+------+
| recno | int4 |4 |
| custid | int4 |4 |
| username | char() not null |14 |
| service | int4 |4 |
+----------------------------------+------------------------------+------+
???
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] '' != NULL in PostGres???
1998-09-23 17:41 '' != NULL in PostGres??? Neil Harkins <nharkins@well.com>
@ 1998-09-23 18:10 ` Brook Milligan <brook@trillium.NMSU.Edu>
1998-09-23 18:57 ` Re: [SQL] '' != NULL in PostGres??? Colin Dick <cdick@mail.ocis.net>
0 siblings, 1 reply; 4+ messages in thread
From: Brook Milligan @ 1998-09-23 18:10 UTC (permalink / raw)
To: nharkins@well.com; +Cc: pgsql-sql
nuacct=> create table users (
nuacct-> recno int,
nuacct-> custid int unique,
nuacct-> username char(14) not null,
nuacct-> service int
nuacct-> );
nuacct=> insert into users values
nuacct-> ( 0, 0, '', 0 );
INSERT 18241 1
??? Shouldn't that have failed, generating an error ???
No, but this will:
nuacct=> insert into users values ( 0, 0, null, 0 );
'' is a zero length string not a null.
Cheers,
Brook
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] '' != NULL in PostGres???
1998-09-23 17:41 '' != NULL in PostGres??? Neil Harkins <nharkins@well.com>
1998-09-23 18:10 ` Re: [SQL] '' != NULL in PostGres??? Brook Milligan <brook@trillium.NMSU.Edu>
@ 1998-09-23 18:57 ` Colin Dick <cdick@mail.ocis.net>
1998-09-23 21:49 ` Re: [SQL] '' != NULL in PostGres??? James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 1 reply; 4+ messages in thread
From: Colin Dick @ 1998-09-23 18:57 UTC (permalink / raw)
To: Brook Milligan <brook@trillium.NMSU.Edu>; +Cc: nharkins@well.com; pgsql-sql
> nuacct=> create table users (
> nuacct-> recno int,
> nuacct-> custid int unique,
> nuacct-> username char(14) not null,
> nuacct-> service int
> nuacct-> );
>
> nuacct=> insert into users values
> nuacct-> ( 0, 0, '', 0 );
> INSERT 18241 1
>
> ??? Shouldn't that have failed, generating an error ???
>
> No, but this will:
>
> nuacct=> insert into users values ( 0, 0, null, 0 );
>
> '' is a zero length string not a null.
I wonder,
Would
insert into users (recno, custid, service) values (0, 0, 0);
also fail? As far as I can tell, if you don't expressly populate the
field, it will remain as a null....
--
Colin Dick
On Call Internet Services
cdick@mail.ocis.net
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] '' != NULL in PostGres???
1998-09-23 17:41 '' != NULL in PostGres??? Neil Harkins <nharkins@well.com>
1998-09-23 18:10 ` Re: [SQL] '' != NULL in PostGres??? Brook Milligan <brook@trillium.NMSU.Edu>
1998-09-23 18:57 ` Re: [SQL] '' != NULL in PostGres??? Colin Dick <cdick@mail.ocis.net>
@ 1998-09-23 21:49 ` James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 0 replies; 4+ messages in thread
From: James Olin Oden @ 1998-09-23 21:49 UTC (permalink / raw)
To: Colin Dick <cdick@mail.ocis.net>; pgsql-sql
> I wonder,
> Would
>
> insert into users (recno, custid, service) values (0, 0, 0);
>
> also fail? As far as I can tell, if you don't expressly populate the
> field, it will remain as a null....
I believe that would should fail unless he has set some sort of default
value for the field...james
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1998-09-23 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-09-23 17:41 '' != NULL in PostGres??? Neil Harkins <nharkins@well.com>
1998-09-23 18:10 ` Brook Milligan <brook@trillium.NMSU.Edu>
1998-09-23 18:57 ` Colin Dick <cdick@mail.ocis.net>
1998-09-23 21:49 ` James Olin Oden <joden@lee.k12.nc.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox