pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Autogenerated Unique Index
9+ messages / 4 participants
[nested] [flat]

* Autogenerated Unique Index
@ 2000-03-07 13:41  Antonio W. Lagnada <alagnada@lsil.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Antonio W. Lagnada @ 2000-03-07 13:41 UTC (permalink / raw)
  To: pgsql-sql

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

Attachments:

alagnada.vcf (text/x-vcard, 412B) download 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
^ permalink raw reply [nested|flat] 9+ messages in thread

* RE: [SQL] Autogenerated Unique Index
@ 2000-03-07 14:30  Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
  0 siblings, 2 replies; 9+ messages in thread

From: Andrzej Mazurkiewicz @ 2000-03-07 14:30 UTC (permalink / raw)
  To: 'Antonio W. Lagnada' <alagnada@lsil.com>; pgsql-sql

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 >> 



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [SQL] Autogenerated Unique Index
@ 2000-03-07 15:05  Antonio W. Lagnada <alagnada@lsil.com>
  parent: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
  1 sibling, 1 reply; 9+ messages in thread

From: Antonio W. Lagnada @ 2000-03-07 15:05 UTC (permalink / raw)
  To: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>; +Cc: pgsql-sql

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

Attachments:

alagnada.vcf (text/x-vcard, 412B) download 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
^ permalink raw reply [nested|flat] 9+ messages in thread

* RE: [SQL] Autogenerated Unique Index
@ 2000-03-07 15:11  Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
  0 siblings, 1 reply; 9+ messages in thread

From: Andrzej Mazurkiewicz @ 2000-03-07 15:11 UTC (permalink / raw)
  To: 'Antonio W. Lagnada' <alagnada@lsil.com>; +Cc: pgsql-sql

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 >> 



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [SQL] Autogenerated Unique Index
@ 2000-03-07 15:29  Antonio W. Lagnada <alagnada@lsil.com>
  parent: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
  0 siblings, 0 replies; 9+ messages in thread

From: Antonio W. Lagnada @ 2000-03-07 15:29 UTC (permalink / raw)
  To: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>; +Cc: pgsql-sql

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

Attachments:

alagnada.vcf (text/x-vcard, 412B) download 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
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: [SQL] Autogenerated Unique Index
@ 2000-03-07 15:32  Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
  parent: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
  1 sibling, 0 replies; 9+ messages in thread

From: Ross J. Reedstrom @ 2000-03-07 15:32 UTC (permalink / raw)
  To: 'Antonio W. Lagnada' <alagnada@lsil.com>; +Cc: pgsql-sql

On Tue, Mar 07, 2000 at 03:30:38PM +0100, 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=>

Hmm, I bet Antonio is looking for an automatic sequence type, rather
than the 'autogenerated index' that he asks about. That'd be like:

test=> create table A (
test-> B serial,
test-> C text);
NOTICE:  CREATE TABLE will create implicit sequence 'a_b_seq' for SERIAL column 'a.b'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'a_b_key' for table 'a'
CREATE
test=> 

If you need more, look for "SERIAL" in ther docs.

Ross
-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* RE: [SQL] Autogenerated Unique Index
@ 2000-03-07 15:37  Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
  0 siblings, 0 replies; 9+ messages in thread

From: Andrzej Mazurkiewicz @ 2000-03-07 15:37 UTC (permalink / raw)
  To: 'Antonio W. Lagnada' <alagnada@lsil.com>; +Cc: pgsql-sql



> -----Original Message-----
> From:	Antonio W. Lagnada [SMTP:alagnada@lsil.com]
> Sent:	7 marca 2000 16:29
> To:	Andrzej Mazurkiewicz
> Cc:	Pgsql-sql
> Subject:	Re: [SQL] Autogenerated Unique Index
> 
> Hi Andrzej,
> 
> From reading the Users Guide, I came up with this example
	[Andrzej Mazurkiewicz]  
	[Andrzej Mazurkiewicz]  CREATE SEQUENCE id START 1;

	[Andrzej Mazurkiewicz]  
> # To create the table with the auto-incrementing index
> CREATE TABLE customer ( id  [Andrzej Mazurkiewicz]  int , firstname
> VARCHAR(30), lastname VARCHAR(30)
> );
> 
> # To insert
> INSERT INTO customer VALUES ( NEXTVAL('id'),'John','Doe');
> INSERT INTO customer VALUES ( NEXTVAL('id'),'Jane','Doe');
	[Andrzej Mazurkiewicz]  please remember that the above id refers to
SERIAL name not to column name !


> # 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
>  << File: Card for Antonio W. Lagnada >> 



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [SQL] Autogenerated Unique Index
@ 2000-03-07 15:37  Trurl McByte <trurl@realtor3d.odessa.ua>
  parent: Antonio W. Lagnada <alagnada@lsil.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Trurl McByte @ 2000-03-07 15:37 UTC (permalink / raw)
  To: Antonio W. Lagnada <alagnada@lsil.com>; +Cc: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>; pgsql-sql

On Tue, 7 Mar 2000 (Today), Antonio W. Lagnada wrote:

Try "serial" macro-type off "id" field.

#CREATE TABLE A (
#	B serial,
#	C char(5)
#);
NOTICE:  CREATE TABLE will create implicit sequence 'a_b_seq' for SERIAL column'a.b'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'a_b_key' for table 'a'
CREATE 

Or make it by hand:

#CREATE SEQUENCE A_B_seq;
#CREATE TABLE A (
#	B int DEFAULT nextval('A_B_seq') NOT NULL,
#	C char(5),
#	PRIMARY KEY(B)
#);
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'a_pkey' for table'a'  
CREATE

  AWL> Hi Andrzej,
  AWL> 
  AWL> Does this mean that everytime I create a new record on the table, the field
  AWL> "B" will be automatically incremented?
  AWL> 
  AWL> - Antonio
  AWL> 
  AWL> Andrzej Mazurkiewicz wrote:
  AWL> 
  AWL> > cfmg_adm=> CREATE TABLE A (
  AWL> > cfmg_adm(>        B int NOT NULL,
  AWL> > cfmg_adm(>        C char(5),
  AWL> > cfmg_adm(> PRIMARY KEY (B)
  AWL> > cfmg_adm(> );
  AWL> > NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'a_pkey' for
  AWL> > table
  AWL> > 'a'
  AWL> > CREATE
  AWL> > cfmg_adm=>
  AWL> > Regards,
  AWL> > Andrzej Mazurkiewicz
  AWL> >
  AWL> > > -----Original Message-----
  AWL> > > From: Antonio W. Lagnada [SMTP:alagnada@lsil.com]
  AWL> > > Sent: 7 marca 2000 14:41
  AWL> > > To:   Pgsql-sql
  AWL> > > Subject:      [SQL] Autogenerated Unique Index
  AWL> > >
  AWL> > > Can someone give me a step-by-step instructions on how to generate a
  AWL> > > unique autogenerated index in PostgreSQL?
  AWL> > >
  AWL> > > --
  AWL> > > Antonio W. Lagnada
  AWL> > >
  AWL> > >
  AWL> > > 952.921.8533
  AWL> > > alagnada@lsil.com_NOSPAM
  AWL> > > Remove the _NOSPAM for
  AWL> > > the actual email address
  AWL> > >  << File: Card for Antonio W. Lagnada >>
  AWL> 
  AWL> --
  AWL> Antonio W. Lagnada
  AWL> 
  AWL> 952.921.8533
  AWL> alagnada@lsil.com_NOSPAM
  AWL> Remove the _NOSPAM for
  AWL> the actual email address
  AWL> 
  AWL> 

-- 
      Trurl McByte, Capt. of StasisCruiser "Prince"
|InterNIC: AR3200                   RIPE: AR1627-RIPE|
|--98 C3 78 8E 90 E3 01 35  87 1F 3F EF FD 6D 84 B3--|




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: [SQL] Autogenerated Unique Index
@ 2000-03-07 16:46  Antonio W. Lagnada <alagnada@lsil.com>
  parent: Trurl McByte <trurl@realtor3d.odessa.ua>
  0 siblings, 0 replies; 9+ messages in thread

From: Antonio W. Lagnada @ 2000-03-07 16:46 UTC (permalink / raw)
  To: Trurl McByte <trurl@realtor3d.odessa.ua>; +Cc: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>; pgsql-sql

Hi Trurl,

#CREATE SEQUENCE A_B_seq;
#CREATE TABLE A (
#       B int DEFAULT nextval('A_B_seq') NOT NULL,
#       C char(5),
#       PRIMARY KEY(B)
#);

I think the above is what I'm looking for....Thanks to All :-)

Trurl McByte wrote:

> On Tue, 7 Mar 2000 (Today), Antonio W. Lagnada wrote:
>
> Try "serial" macro-type off "id" field.
>
> #CREATE TABLE A (
> #       B serial,
> #       C char(5)
> #);
> NOTICE:  CREATE TABLE will create implicit sequence 'a_b_seq' for SERIAL column'a.b'
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'a_b_key' for table 'a'
> CREATE
>
> Or make it by hand:
>
> #CREATE SEQUENCE A_B_seq;
> #CREATE TABLE A (
> #       B int DEFAULT nextval('A_B_seq') NOT NULL,
> #       C char(5),
> #       PRIMARY KEY(B)
> #);
> NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'a_pkey' for table'a'
> CREATE
>
>   AWL> Hi Andrzej,
>   AWL>
>   AWL> Does this mean that everytime I create a new record on the table, the field
>   AWL> "B" will be automatically incremented?
>   AWL>
>   AWL> - Antonio
>   AWL>
>   AWL> Andrzej Mazurkiewicz wrote:
>   AWL>
>   AWL> > cfmg_adm=> CREATE TABLE A (
>   AWL> > cfmg_adm(>        B int NOT NULL,
>   AWL> > cfmg_adm(>        C char(5),
>   AWL> > cfmg_adm(> PRIMARY KEY (B)
>   AWL> > cfmg_adm(> );
>   AWL> > NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'a_pkey' for
>   AWL> > table
>   AWL> > 'a'
>   AWL> > CREATE
>   AWL> > cfmg_adm=>
>   AWL> > Regards,
>   AWL> > Andrzej Mazurkiewicz
>   AWL> >
>   AWL> > > -----Original Message-----
>   AWL> > > From: Antonio W. Lagnada [SMTP:alagnada@lsil.com]
>   AWL> > > Sent: 7 marca 2000 14:41
>   AWL> > > To:   Pgsql-sql
>   AWL> > > Subject:      [SQL] Autogenerated Unique Index
>   AWL> > >
>   AWL> > > Can someone give me a step-by-step instructions on how to generate a
>   AWL> > > unique autogenerated index in PostgreSQL?
>   AWL> > >
>   AWL> > > --
>   AWL> > > Antonio W. Lagnada
>   AWL> > >
>   AWL> > >
>   AWL> > > 952.921.8533
>   AWL> > > alagnada@lsil.com_NOSPAM
>   AWL> > > Remove the _NOSPAM for
>   AWL> > > the actual email address
>   AWL> > >  << File: Card for Antonio W. Lagnada >>
>   AWL>
>   AWL> --
>   AWL> Antonio W. Lagnada
>   AWL>
>   AWL> 952.921.8533
>   AWL> alagnada@lsil.com_NOSPAM
>   AWL> Remove the _NOSPAM for
>   AWL> the actual email address
>   AWL>
>   AWL>
>
> --
>       Trurl McByte, Capt. of StasisCruiser "Prince"
> |InterNIC: AR3200                   RIPE: AR1627-RIPE|
> |--98 C3 78 8E 90 E3 01 35  87 1F 3F EF FD 6D 84 B3--|

--
Antonio W. Lagnada
Silicon Optimization

952.921.8533
alagnada@lsil.com_NOSPAM
Remove the _NOSPAM for
the actual email address

Attachments:

alagnada.vcf (text/x-vcard, 412B) download 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
^ permalink raw reply [nested|flat] 9+ messages in thread


end of thread, other threads:[~2000-03-07 16:46 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-03-07 13:41 Autogenerated Unique Index Antonio W. Lagnada <alagnada@lsil.com>
2000-03-07 14:30 RE: [SQL] Autogenerated Unique Index Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
2000-03-07 15:05 ` Antonio W. Lagnada <alagnada@lsil.com>
2000-03-07 15:37   ` Trurl McByte <trurl@realtor3d.odessa.ua>
2000-03-07 16:46     ` Antonio W. Lagnada <alagnada@lsil.com>
2000-03-07 15:32 ` Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
2000-03-07 15:11 RE: [SQL] Autogenerated Unique Index Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
2000-03-07 15:29 ` Antonio W. Lagnada <alagnada@lsil.com>
2000-03-07 15:37 RE: [SQL] Autogenerated Unique Index Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>

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