Monday, March 26, 2012

How can I change PRIMARY KEY using code?

Hi,
Assume I have a PRIMARY KEY on one column.
How can I change PRIMARY KEY onto a new column using code?
Do I have to recreate the table?
Thanks.Hi
Here is the code to solve your problem
ALTER TABLE <TABLE_NAME>
DROP CONSTRAINT <Constraint_Name>
ALTER TABLE <TABLE_NAME>
ADD CONSTRAINT <Constraint_Name> PRIMARY KEY (<Column> )
best Regards,
Chandra
---
"§Chrissi§" wrote:

> Hi,
> Assume I have a PRIMARY KEY on one column.
> How can I change PRIMARY KEY onto a new column using code?
> Do I have to recreate the table?
> Thanks

No comments:

Post a Comment