Question

I have a table arp_table in which there are values ip,mac and time. I currently have ip as the primary key but i would like to modify so that it can become both the ip and the time. This is to enable an entry with the same ip but a different time to be entered. I was assuming the code

alter table arp_table
modify PRIMARY KEY(ip,time) 

would work but it is not working. I am using mysql database

Was it helpful?

Solution

You have first to drop the existing one:

ALTER TABLE arp_table DROP PRIMARY KEY, ADD PRIMARY KEY(ip,time) 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top