Re: Alter table Add Primary Key

From: "zammon(at)libero(dot)it" <zammon(at)libero(dot)it>
To: Ana Claudia <ana-b-dias(at)ptinovacao(dot)pt>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Alter table Add Primary Key
Date: 2001-10-03 09:05:27
Message-ID: 3BBAD4D7.9030404@libero.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Ola Ana Claudia.
You can add a primary key to your table using:
CREATE INDEX ...command
I hope this help you.

José Soares

>Hello,
>
>I'd like to know if is possible create a primary key in a table that already
>exits in database (note: in Oracle is possible), because I try do that and I
>received an ERROR MESSAGES
>
>Example:
>/*Script taht I used to create the table*/
>CREATE TABLE tespri
>(
>pri NUMERIC(3,0) NOT NULL CHECK (pri between 0 and 255),
>sec VARCHAR(4) NOT NULL CHECK (sec<> 'ana')
>);
>
>
>/* End of Script */
>
>
>
>teste=# \d tespri
> Table "tespri"
> Attribute | Type | Modifier
>-----------+----------------------+----------
> pri | numeric(3,0) | not null
> sec | character varying(4) | not null
>Constraints: ((pri >= '0'::"numeric") AND (pri <= '255'::"numeric"))
> (sec <> 'ana'::"varchar")
>
>teste=# alter table tespri add constraint ck1 PRIMARY KEY(pri);
>ERROR: ALTER TABLE / ADD CONSTRAINT is not implemented for that constraint
>type.
>teste=#
>
>/* NOTE: database name teste table name tespri */
>
>Thanks for everything.
>Best Regards,
>Cláudia
>
>
>
>Ana Cláudia Dias
>Aveiro - Portugal
>
>Email: ana-b-dias(at)ptinovacao(dot)pt
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mourad EL HADJ MIMOUNE 2001-10-03 09:52:55 SQLProgrammer
Previous Message Andrea Aime 2001-10-03 06:42:15 Re: VB 6 pro to postgres suggestion needed