Re: Table with default value - Mailing list pgsql-novice

From Oliver Elphick
Subject Re: Table with default value
Date
Msg-id 1010747706.781.2.camel@linda
Whole thread Raw
In response to Table with default value  (Sharon Cowling <sharon.cowling@sslnz.com>)
List pgsql-novice
On Fri, 2002-01-11 at 03:14, Sharon Cowling wrote:
>
> user=> \d
>                      Table "person4"
>     Attribute     |         Type          |   Modifier
> ------------------+-----------------------+--------------
...
>  drivers_licence  | character varying(20) | default 'No'
...
>
> user=> select * from person4;
>  person_id | firstname | lastname |    dob     | street | suburb | city | homephone | workphone | mobile |      type
   | date_approved | approved_by | vehicle_type | vehicle_rego | drivers_licence | firearms_licence | notes 
>
-----------+-----------+----------+------------+--------+--------+------+-----------+-----------+--------+----------------+---------------+-------------+--------------+--------------+-----------------+------------------+-------
>        778 | sdf       | sdf      | 11/11/1977 | sf     |        | dsf  |           |           |        |
Owner/Relative| 11/01/2002    | test        |              |              |                 |                  | 
> (1 row)
>
> As you can see there is no default value of 'No' for drivers licence.

The default only operates if you do an insert without mentioning the
column.  It will not override an explicitly inserted null or empty
string.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C

     "Enter into his gates with thanksgiving, and into his
      courts with praise. Be thankful unto him, and bless
      his name."           Psalms 100:4

Attachment

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: How do you do a subselect in postgresql?
Next
From: Andreas Fitzner
Date:
Subject: length(columnname)<=31 ?