Вопрос

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

Это было полезно?

Решение

You have first to drop the existing one:

ALTER TABLE arp_table DROP PRIMARY KEY, ADD PRIMARY KEY(ip,time) 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top