Re: entering empty value - Mailing list pgsql-general

From Gregory Wood
Subject Re: entering empty value
Date
Msg-id 003601c1ba9b$8ca58700$7889ffcc@comstock.com
Whole thread Raw
In response to Re: entering empty value  (missive@frontiernet.net (Lee Harr))
Responses Re: entering empty value  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
> > I have a table with records where sometimes a value should be kept empty
> > e.g. faxnumber is sometime empty because not everybody owns a fax. What
> > is the syntax for entering the data for such a record with  an empty
> > value?
>
> create table t (a int, b text);
>
> insert into t values(1, NULL)

Actually, to be anal, a NULL value is used to denote an undefined or unknown
value. If the value is known to be empty (and assuming this is stored in a
string field such as TEXT or VARCHAR), it might be more appropriate to say:

insert into t values (1,'');

This is especially true as empty strings can be used in an index, while NULL
values, to the best of my knowledge, do not appear in indexes.

Greg


pgsql-general by date:

Previous
From: virka prasetia
Date:
Subject: OID
Next
From: Tom Lane
Date:
Subject: Re: entering empty value