Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.2/8.9.1) with ESMTP id NAA55919 for ; Fri, 26 Feb 1999 13:31:51 -0500 (EST) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id MAA09466; Fri, 26 Feb 1999 12:31:50 -0600 (CST) Received: from cpsmail.cpsgroup.com(144.210.12.11) by gauntlet.bjke.com via smap (4.1) id xmaa09136; Fri, 26 Feb 99 12:31:25 -0600 Received: by cpsmail with Internet Mail Service (5.0.1458.49) id ; Fri, 26 Feb 1999 12:34:21 -0600 Message-ID: From: "Jackson, DeJuan" To: Patrice DUMAS , pgsql-sql@postgreSQL.org Subject: RE: [SQL] Unique Number KEY Date: Fri, 26 Feb 1999 12:34:19 -0600 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.org id NAA55921 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 > > >