Re: entering empty value

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: entering empty value
Date: 2002-02-21 05:48:18
Message-ID: 003601c1ba9b$8ca58700$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-21 06:15:09 Re: entering empty value
Previous Message Rich Shepard 2002-02-21 04:31:59 Re: batch file