سؤال

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