pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jackson, DeJuan <djackson@cpsgroup.com>
To: Patrice DUMAS <pdumas@inforoutes-ardeche.fr>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] Unique Number KEY
Date: Fri, 26 Feb 1999 12:34:19 -0600
Message-ID: <F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail> (raw)

CREATE TABLE students (
  Student_Number SERIAL PRIMARY KEY,
  Student_Name   VARCHAR(40)
);
Then:
 INSERT INTO students(student_name) VALUES('Fred Strauss');
 -- Student_Number should be 1

SERIAL will auto-create a sequence for you.
Look up SEQUENCES in the docs for more info on how to access and manage
the auto generated number.

> -----Original Message-----
> From: Patrice DUMAS [mailto:pdumas@inforoutes-ardeche.fr]
> Sent: Friday, February 26, 1999 11:43 AM
> To: pgsql-sql@postgreSQL.org
> Subject: [SQL] Unique Number KEY
> 
> 
> Hello,
> 
> What is the best way, with PostGres, to create a Unique Number Key
> Generator?
> 
> 
> For example, I have a STUDENTS table:
> {
>     StudentNumber    integer;
>     StudentName      char[40];
> ...
> }
> 
> Beginner in SQL, I think I must use Primary key or something 
> like that, to
> be sure StudentNumber is unique.
> But, I want StudentNumber to be generated automatically, the 
> user don't
> worry in assigning a StudentNumber.
> 
> What is the best way to do that with PostGres-SQL ?
> 
> Thank you for your answers and sorry for my poor english,
> 
> 
> 
> 
> Patrice DUMAS
> Ardèche, FRANCE.
> pdumas@inforoutes-ardeche.fr
> 
> 
> 



view thread (4+ messages)  latest in thread

Message-ID: <F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail>
Permalink:  ../F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail/
Also on:    postgresql.org/message-id/F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail

 · 

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: djackson@cpsgroup.com, pdumas@inforoutes-ardeche.fr
  Subject: Re: [SQL] Unique Number KEY
  In-Reply-To: <F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail>
  References: <F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail>

* 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