0 votes
1 view
in SQL by (22.4k points)

I have a table called provider. I have three columns called a person, place, thing. There can be duplicate persons, duplicate places, and duplicate things, but there can never be a duplicate person-place-thing combination.

How would I ALTER TABLE to add a composite primary key for this table in MySQL with these three columns?

1 Answer

0 votes
by (40.3k points)

Try the code given below:

Query

ALTER TABLE provider ADD PRIMARY KEY(person,place,thing);

If the primary key already exists then you need to use the code as follows:

Query

ALTER TABLE provider DROP PRIMARY KEY, ADD PRIMARY KEY(person, place, thing);

Related questions

+1 vote
1 answer
0 votes
0 answers
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...