Re: [GENERAL] primary key attribute - Mailing list pgsql-general

From Oliver Elphick
Subject Re: [GENERAL] primary key attribute
Date
Msg-id 199805292315.AAA07848@linda.lfix.co.uk
Whole thread Raw
In response to Re: [GENERAL] primary key attribute  (Billy Donahue <donahu@cooper.edu>)
List pgsql-general
Billy Donahue wrote:
  >Joao Paulo Felix wrote:
  >>
  >> Hi there,
  >>
  >> I am having trouble trying to alter a class and update an column
  >> constraint to PRIMARY KEY. I decided to create a new table using the
  >> following, still it does seem work:
  >>
  >> CREATE TABLE my_table
  >>
  >>         (my_column INT PRIMARY KEY, my_column2 TEXT);
  >>
  >> Could any one help me please. Thanks in advance.
  >>
  >> Joao Paulo
  >
  >I'm new to this myself, but I know there's no
  >PRIMARY KEY in the SQL subset supported by PostgreSQL.

Your information is out of date.  6.3.2 does support the PRIMARY KEY
constraint. Here are two examples that work:

create table price
(
    product        char(8)        primary key
                        references product (id),
    unit        text        default 'each',
    cost        money        not null,
    home        money        not null,
    export        money        not null,
    next_home    money,
    next_export    money
)
;

create table batch_issues
(
    product        char(8)        not null
                        references product (id),
    batch        int        not null,
    stamp        datetime    not null
                    default datetime(now()),
    type        char(1)        not null,
    ref        char(5),
    qty        int        not null,

    primary key (product, batch, stamp),
    foreign key (product, batch) references batch
);

[the foreign key bits are parsed but have no effect, in 6.3.2]

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "Let no man despise thy youth; but be thou an example
      of the believers, in word, in conversation, in
      charity, in spirit, in faith, in purity."
                                       I Timothy 4:12



pgsql-general by date:

Previous
From: Zinchik
Date:
Subject: unsubscribe
Next
From: Mark Pulver
Date:
Subject: Pg.pm and friends