RE: [SQL] Unique Number KEY

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: Patrice DUMAS <pdumas(at)inforoutes-ardeche(dot)fr>, pgsql-sql(at)postgreSQL(dot)org
Subject: RE: [SQL] Unique Number KEY
Date: 1999-02-26 18:34:19
Message-ID: F10BB1FAF801D111829B0060971D839F6B94AC@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)inforoutes-ardeche(dot)fr]
> Sent: Friday, February 26, 1999 11:43 AM
> To: pgsql-sql(at)postgreSQL(dot)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(at)inforoutes-ardeche(dot)fr
>
>
>

Browse pgsql-sql by date

  From Date Subject
Next Message David Martinez Cuevas 1999-02-26 20:51:56 Re: [SQL] CREATE TABLE
Previous Message CIMPOESU Teodor 1999-02-26 18:25:17 Re: [SQL] Unique Number KEY