Thread: primary key

primary key

From
Andrea Antibo
Date:
I trust this query on postgresql 6.2.x



CREATE TABLE films (
       code      CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
       title     CHARACTER VARYING(40) NOT NULL,
       did      DECIMAL(3) NOT NULL,
       date_prod DATE,
       kind     CHAR(10),
       len       INTERVAL HOUR TO MINUTE     );


but I have error near CONSTRAINT.

Maybe this version of postgres can't accept the primary key?


Re: [GENERAL] primary key

From
Herouth Maoz
Date:
At 16:35 +0200 on 9/9/98, Andrea Antibo wrote:


> CREATE TABLE films (
>        code      CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
>        title     CHARACTER VARYING(40) NOT NULL,
>        did      DECIMAL(3) NOT NULL,
>        date_prod DATE,
>        kind     CHAR(10),
>        len       INTERVAL HOUR TO MINUTE     );
>
>
> but I have error near CONSTRAINT.
>
> Maybe this version of postgres can't accept the primary key?

True. No primary keys in 6.2.x. Just create a unique index on the code
field after creating the table (preferably, after loading data, if there is
any).

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma



Re: [GENERAL] primary key

From
Sferacarta Software
Date:
Ciao Andrea,

mercoledì, 9 settembre 98, you wrote:

AA> I trust this query on postgresql 6.2.x



AA> CREATE TABLE films (
AA>        code      CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
AA>        title     CHARACTER VARYING(40) NOT NULL,
AA>        did      DECIMAL(3) NOT NULL,
AA>        date_prod DATE,
AA>        kind     CHAR(10),
AA>        len       INTERVAL HOUR TO MINUTE     );


AA> but I have error near CONSTRAINT.

AA> Maybe this version of postgres can't accept the primary key?


PostgreSQL 6.2 hasn't this feature, you need v-6.3.2.


Best regards,
  Jose'                            mailto:sferac@bo.nettuno.it