Re: NULL values

Поиск
Список
Период
Сортировка
От Chad R. Larson
Тема Re: NULL values
Дата
Msg-id 20010710155013.B1547@ecibsd1.ecinet.com
обсуждение исходный текст
Ответ на NULL values  ("Mark Muffett" <mark@muffett.net>)
Список pgsql-general
On Tue, Jul 10, 2001 at 09:40:31AM +0100, Mark Muffett wrote:
> Is there a Postgresql equivalent to the Oracle NVL( ) function,
> which allows a SELECT statement to fill in default values if a
> column is NULL?

Yes.

Use the DEFAULT keyword while creating the table.

That is:

    CREATE TABLE account (
    name    CHAR(20),
    balance    NUMERIC(16,2) DEFAULT 0,
    active    CHAR(2) DEFAULT 'Y',
    created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );

Then :

    INSERT INTO account (name)
    VALUES ('Federated Builders');

will leave the inserted rows with no nulls, but the balance will be
zero, and the "created" field will have the date/time of the insert.

> Mark Muffett

         -crl
--
Chad R. Larson (CRL22)    chad@eldocomp.com
  Eldorado Computing, Inc.   602-604-3100
     5353 North 16th Street, Suite 400
       Phoenix, Arizona   85016-3228

В списке pgsql-general по дате отправления:

Предыдущее
От: "Mark G. Franz"
Дата:
Сообщение: Re: Grab data WHERE table.ID NOT LIKE otherTable.ID
Следующее
От: Nils Zonneveld
Дата:
Сообщение: Re: Postgresql revisited. Some questions about the product