Thread

  1. How to have a autoincrement field?

    Marc Eggenberger <me@ieo.ch> — 1998-10-06T08:17:08Z

    Hi there.
    
    I'm making my first steps on postgreSQL on a Sun Solaris.
    
    With the current database I need a field that is automaticly incremented when data is added.
    I looked in the docs, and the mailinglist archive ... could find any suitable ...
    
    Can someone help?
    
    
    --
    mit freundlichen Gruessen
    =====================================
    Egenberger Marc            me@ieo.ch
    Leimbachstr. 56        Tel 01/4802800
    8041 Zuerich            Fax 01/4802801
    =====================================
    
    
  2. Re: [GENERAL] How to have a autoincrement field?

    Kevin Heflin <kheflin@shreve.net> — 1998-10-06T08:36:49Z

    On Tue, 6 Oct 1998, Marc Eggenberger wrote:
    
    > With the current database I need a field that is automaticly
    > incremented when data is added. I looked in the docs, and the
    > mailinglist archive ... could find any suitable ...
    
    I suppose there may be an easier/better way than this. But what I do when
    I create the table I create a sequence, then have a field which
    automatically increments the field ... Like so:
    
    CREATE SEQUENCE game_id;
    
    CREATE TABLE games (
            game_id INT DEFAULT nextval('game_id') PRIMARY KEY,
            game_title varchar (250),
    	etc....
    	)
    
    Hope that helps.
    
    Kevin
    
    
    
    --------------------------------------------------------------------
    Kevin Heflin          | ShreveNet, Inc.      | Ph:318.222.2638 x103
    VP/Mac Tech           | 333 Texas St #619    | FAX:318.221.6612
    kheflin@shreve.net    | Shreveport, LA 71101 | http://www.shreve.net
    --------------------------------------------------------------------