pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Walker <solar92@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: Serial field starting at 100 ?
Date: Fri, 07 Jan 2000 02:35:09 GMT
Message-ID: <20000107023509.41287.qmail@hotmail.com> (raw)

Hello,

In SQLServer, you can do this:

CREATE TABLE fish (
    fishID INTEGER IDENTITY (100, 1) NOT NULL,
    fishName VARCHAR(32) NOT NULL
);

When inserting into that table, you don't mention the first field
and it will automatically use add 1 to the last value in that field,
starting with 100 for the first record.
If you wanted it to start at 25 and increment by 5, you'd put
fishID INTEGER IDENTITY (25, 5) NOT NULL.

I'd like to do something similar to this in PostgreSQL, but the
closest I can get requires that I mention the implicit sequence which
seems unneccessary hassle:

CREATE TABLE fish (
    fishID INT4 SERIAL
    fishName VARCHAR(32) NOT NULL
);

SELECT setval('fish_fishID_seq',99);

(Incrementing by 1 is fine by me).
Is there any way I can do something like:
fishID INT4 SERIAL (100, 1)
or
fishID INT4 SERIAL (START 100)   ?

- Rick


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com




view thread (3+ messages)  latest in thread

Message-ID: <20000107023509.41287.qmail@hotmail.com>
Permalink:  ../20000107023509.41287.qmail@hotmail.com/
Also on:    postgresql.org/message-id/20000107023509.41287.qmail@hotmail.com

 · 

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: solar92@hotmail.com
  Subject: Re: Serial field starting at 100 ?
  In-Reply-To: <20000107023509.41287.qmail@hotmail.com>
  References: <20000107023509.41287.qmail@hotmail.com>

* 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