RE: [SQL] Unique Number KEY - Mailing list pgsql-sql

From Jackson, DeJuan
Subject RE: [SQL] Unique Number KEY
Date
Msg-id F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail
Whole thread Raw
List pgsql-sql
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
>
>
>

pgsql-sql by date:

Previous
From: CIMPOESU Teodor
Date:
Subject: Re: [SQL] Unique Number KEY
Next
From: David Martinez Cuevas
Date:
Subject: Re: [SQL] CREATE TABLE