From: | "Chad R(dot) Larson" <chad(at)eldocomp(dot)com> |
---|---|
To: | Mark Muffett <mark(at)muffett(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: NULL values |
Date: | 2001-07-10 22:50:13 |
Message-ID: | 20010710155013.B1547@ecibsd1.ecinet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)eldocomp(dot)com
Eldorado Computing, Inc. 602-604-3100
5353 North 16th Street, Suite 400
Phoenix, Arizona 85016-3228
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2001-07-10 22:54:27 | Re: Stored Procedure Newbie |
Previous Message | Tom Lane | 2001-07-10 22:49:08 | Re: Stored Procedure Newbie |