Subject Re: [firebird-support] how to define another primary key in the table?
Author Martijn Tonies
Hi,

> I have a table with ID field defined as PK. ID is integer, i have a
> generator, and putting a value for ID manually from the client
> application.
>
> Now i need to create another field, ID2 to be a PK in the table.
> I also need to auto create generator and trigger to populate this field.
>
> How do i remove a PK-mark from "ID" field and populate ID2 field for
> existing rows?

You can drop the primary key by ALTER TABLE <mytable> DROP
CONSTRAINT <name>

Then add the new PK by using ALTER TABLE <mytable> ADD
CONSTRAINT <newname> PRIMARY KEY (columns)

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com