Re: How to set a Default Value

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Ângelo Marcos Rigo <angelo_rigo(at)yahoo(dot)com(dot)br>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to set a Default Value
Date: 2006-01-13 13:28:30
Message-ID: E3A2EF99-29E0-4050-B9FD-3CD817BCD436@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Jan 13, 2006, at 22:10 , Ângelo Marcos Rigo wrote:

> I have created a column item varchar(11) with default
> value = 0

How did you set the default to 0? Can we see your table definition
statement? Also, note that 0 is an integer: you probably want
'0' (with the single quotes).

> But when i do insert any record the value is set to
> null.

How are your inserting records? Can we see your insert statement?

> How can i always get the defualt value if any other
> value is not defined (sometimes it will have some
> identification characters)

If you want to guarantee that there will always be *some* value, make
sure you set the column NOT NULL as well.

If this doesn't help, please provide a simple, complete example that
shows the behavior you describe so we may help you further.

Michael Glaesemann
grzm myrealbox com

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2006-01-13 13:29:38 Re: How to set a Default Value
Previous Message Ângelo Marcos Rigo 2006-01-13 13:10:05 How to set a Default Value