Received: from lsi.lsil.com (lsi.lsil.com [147.145.40.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA73705 for ; Tue, 7 Mar 2000 10:28:35 -0500 (EST) (envelope-from alagnada@lsil.com) Received: from mhbs.lsil.com ([147.145.31.100]) by lsi.lsil.com (8.9.3+Sun/8.9.1) with ESMTP id HAA26006 for ; Tue, 7 Mar 2000 07:28:00 -0800 (PST) Received: from [147.145.143.10] by mhbs.lsil.com; Tue, 7 Mar 2000 07:27:56 -0800 Received: from lsil.com by mms10 (SMI-8.6/SMI-SVR4) id JAA18495; Tue, 7 Mar 2000 09:27:51 -0600 Message-Id: <38C52052.5F564026@lsil.com> Date: Tue, 07 Mar 2000 09:29:22 -0600 From: "Antonio W. Lagnada" Organization: LSI Logic Corporation X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Andrzej Mazurkiewicz CC: Pgsql-sql Subject: Re: [SQL] Autogenerated Unique Index References: <13288F4408ADD11186FF0060B06A431303648CA4@MSGWAW1> Content-Type: multipart/mixed; boundary="------------F12965348C51E678458286FF" This is a multi-part message in MIME format. --------------F12965348C51E678458286FF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Andrzej, From reading the Users Guide, I came up with this example # To create the table with the auto-incrementing index CREATE TABLE customer ( id SERIAL, firstname VARCHAR(30), lastname VARCHAR(30) ); # To insert INSERT INTO customer VALUES ( NEXTVAL('id'),'John','Doe'); INSERT INTO customer VALUES ( NEXTVAL('id'),'Jane','Doe'); # This should create a record: id firstname lastname -- --------- -------- 1 John Doe 2 Jane Doe Am I correcto to assume all this? -- Antonio Andrzej Mazurkiewicz wrote: > Sorry I have misunderstood your question. I automatically creates primary > (it is more than unique) INDEX. > I include an example from Postgres Users Manual - CREATE SERIAL section: > > CREATE SEQUENCE serial START 101; > > > Select the next number from this sequence > > SELECT NEXTVAL ('serial'); > > nextval > ------- > 114 > > > Use this sequence in an INSERT: > > INSERT INTO distributors VALUES (NEXTVAL('serial'),'nothing'); > > > Set the sequence value after a COPY FROM: > > CREATE FUNCTION distributors_id_max() RETURNS INT4 > AS 'SELECT max(id) FROM distributors' > LANGUAGE 'sql'; > BEGIN; > COPY distributors FROM 'input_file'; > SELECT setval('serial', distributors_id_max()); > END; > > > I hope it wiull help. > Regards, > Andrzej Mazurkiewicz > > andrzej@mazurkiewicz.org > > www.mazurkiewicz.org > > > -----Original Message----- > > From: Antonio W. Lagnada [SMTP:alagnada@lsil.com] > > Sent: 7 marca 2000 16:05 > > To: Andrzej Mazurkiewicz > > Cc: Pgsql-sql > > Subject: Re: [SQL] Autogenerated Unique Index > > > > Hi Andrzej, > > > > Does this mean that everytime I create a new record on the table, the > > field > > "B" will be automatically incremented? > > > > - Antonio > > > > Andrzej Mazurkiewicz wrote: > > > > > cfmg_adm=> CREATE TABLE A ( > > > cfmg_adm(> B int NOT NULL, > > > cfmg_adm(> C char(5), > > > cfmg_adm(> PRIMARY KEY (B) > > > cfmg_adm(> ); > > > NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index 'a_pkey' > > for > > > table > > > 'a' > > > CREATE > > > cfmg_adm=> > > > Regards, > > > Andrzej Mazurkiewicz > > > > > > > -----Original Message----- > > > > From: Antonio W. Lagnada [SMTP:alagnada@lsil.com] > > > > Sent: 7 marca 2000 14:41 > > > > To: Pgsql-sql > > > > Subject: [SQL] Autogenerated Unique Index > > > > > > > > Can someone give me a step-by-step instructions on how to generate a > > > > unique autogenerated index in PostgreSQL? > > > > > > > > -- > > > > Antonio W. Lagnada > > > > > > > > > > > > 952.921.8533 > > > > alagnada@lsil.com_NOSPAM > > > > Remove the _NOSPAM for > > > > the actual email address > > > > << File: Card for Antonio W. Lagnada >> > > > > -- > > Antonio W. Lagnada > > > > 952.921.8533 > > alagnada@lsil.com_NOSPAM > > Remove the _NOSPAM for > > the actual email address > > << File: Card for Antonio W. Lagnada >> -- Antonio W. Lagnada 952.921.8533 alagnada@lsil.com_NOSPAM Remove the _NOSPAM for the actual email address --------------F12965348C51E678458286FF Content-Type: text/x-vcard; charset=us-ascii; name="alagnada.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Antonio W. Lagnada Content-Disposition: attachment; filename="alagnada.vcf" begin:vcard n:Lagnada;Antonio W. tel;pager:612-414-9149 tel;cell:612-414-9149 tel;fax:612-921-8843 tel;home:651-501-2587 tel;work:612-921-8533 x-mozilla-html:TRUE url:http://www.lsil.com org:LSI Logic Corporation;Silicon Optimization version:2.1 email;internet:alagnada@lsil.com title:Design Engineer adr;quoted-printable:;;8300 Norman Center=0D=0ASuite 730;Bloomington;MN;55437; fn:Antonio W. Lagnada end:vcard --------------F12965348C51E678458286FF--