Skip site navigation (1) Skip section navigation (2)

Syntax error in DROP CONSTRAINT

From: "Rajan Bhide" <rbhide(at)starentnetworks(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Cc: "Ritesh Kumar Kakar" <rkakar(at)starentnetworks(dot)com>
Subject: Syntax error in DROP CONSTRAINT
Date: 2004-11-17 08:02:42
Message-ID: FF851C7EEB75954F9BCFB5CA117AB1EC013FE2E5@delta.nulinkinc.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi Forum,

I need to add a colume to existing composite primary key on a table.
I tried using following:
>> ALTER TABLE DROP CONSTRAINT tablename_pkey;
>> ALTER TABLE ADD CONSTRAINT PRIMARY KEY (col1, col2, col3, new_col4);

When I try this using Postgres 7.2.4 I get psql syntax error in DROP
CONSTRAINT.
ERROR:  parser: parse error at or near ";"

E.g:
CREATE TABLE forwardinginfo
( 
	traptype smallint, 
	trapnumber smallint,
        ipaddr varchar ( 16 ),
	port integer DEFAULT 162, 
        snmpversion smallint,  
	PRIMARY KEY ( traptype, trapnumber, ipaddr, port ) 
);

ALTER TABLE forwardinginfo DROP CONSTRAINT forwardinginfo_pkey;
**** ERROR:  parser: parse error at or near ";" ****

I want to add the new column after droping the existing constraint. 
ALTER TABLE forwardinginfo ADD CONSTRAINT PRIMARY KEY ( traptype,
trapnumber, ipaddr, port, snmpversion);


If I try the same thing with the latest 7.5 version, I see NO error.
How do I perform this with my 7.2.4 postgresql version server?


Thanks,
Rajan.


 

Responses

pgsql-novice by date

Next:From: Matt Arnilo S. BaluyosDate: 2004-11-17 09:12:15
Subject: Previous month function
Previous:From: sarlav kumarDate: 2004-11-16 22:38:35
Subject: Index scan problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group