[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] primary key attribute
From:       "Oliver Elphick" <olly () lfix ! co ! uk>
Date:       1998-05-29 22:15:28
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic