pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adam Lang <aalang@rutgersinsurance.com>
To: pgsql-sql@postgresql.org
Subject: Re: copy from
Date: Tue, 15 Aug 2000 14:07:55 -0400
Message-ID: <010201c006e3$bc6d5ac0$330a0a0a@Adam> (raw)
References: <Pine.BSF.4.10.10008151056120.86873-100000@megazone23.bigpanda.com>

Gotcha. Now, if I do an insert and just don't specify that field at all, it
will, use the default value, correct?  As long as I don't "touch" the field
with anything it uses the default.

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "Stephan Szabo" <sszabo@megazone23.bigpanda.com>
To: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: <pgsql-sql@postgresql.org>
Sent: Tuesday, August 15, 2000 2:00 PM
Subject: Re: [SQL] copy from


>
> Sort of.  You can give the field a default value of
> nextval(<sequence>) which means that if you do not specify
> the column in an insert, it automatically gets the default
> value which should be the next value in the sequence.
> Note, that not putting the column is different from inserting a
> NULL into the field.
>
> (Example:
> sszabo=# create sequence xyzseq;
> CREATE
> sszabo=# create table xyzseqtest ( a int default nextval('xyzseq'), b
> int);
> CREATE
> sszabo=# insert into xyzseqtest (b) values (2);
> INSERT 172188 1
> sszabo=# insert into xyzseqtest (b) values (3);
> INSERT 172189 1
> sszabo=# select * from xyzseqtest;
>  a | b
> ---+---
>  1 | 2
>  2 | 3
> (2 rows)
> )
>
> There are issues about this dealing with rules and triggers where another
> row may be inserted or the default may be evaluated a second time where
> you want to get the value you just inserted back, but in general it works.
>
> On Tue, 15 Aug 2000, Adam Lang wrote:
>
> > Hmmm... well, I don't think I have an "explicit" nextval.  I created the
> > table and then I did a create sequence broker_id;
> >
> > Are you implying that I can set the field to automatically create a
nextval?




view thread (7+ messages)  latest in thread

Message-ID: <010201c006e3$bc6d5ac0$330a0a0a@Adam>
Permalink:  ../010201c006e3$bc6d5ac0$330a0a0a@Adam/
Also on:    postgresql.org/message-id/010201c006e3$bc6d5ac0$330a0a0a@Adam

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: aalang@rutgersinsurance.com
  Subject: Re: copy from
  In-Reply-To: <010201c006e3$bc6d5ac0$330a0a0a@Adam>
  References: <Pine.BSF.4.10.10008151056120.86873-100000@megazone23.bigpanda.com> <010201c006e3$bc6d5ac0$330a0a0a@Adam>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox