SQL String to Modify Multifield Keys

T

TT

I have some existing tables for which I would like to be able to
programmatically alter the primary keys. The tables have multifield primary
keys. For example, a table might have Field1 -- Field5 with Field1 and
Field2 designated as the primary keys. Can anyone give me a sample SQL
command to change the key structure so that the multifield key is Field1,
Field2 and Field3?

Thanks!
 
D

Douglas J. Steele

I'm not sure you can change the structure of an existing index: you may have
to drop it and recreate it.

Dropping would be

DROP INDEX PrimaryKey ON MyTable

(assuming your primary key is actually named PrimaryKey)

I believe recreating would be

CREATE UNIQUE INDEX PrimaryKey
ON MyTable (Field1, Field2, Field3)
WITH PRIMARY
 
Top