Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

simple question...mysql+unique

amonamon
Regular Advisor

simple question...mysql+unique

Helooo,

I have table like this:


CREATE TABLE `actions` (
`id` INT NOT NULL AUTO_INCREMENT ,
`date` INT NOT NULL ,
`time` INT NOT NULL ,
`comp` VARCHAR( 10 ) NOT NULL ,
`target` VARCHAR( 20 ) NOT NULL ,
`action` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
UNIQUE (`id`)
);


Also I have some data in that table but unique field is just id..I have some duplicated data there and I would like to have table like this:

CREATE TABLE `actions` (
`id` INT NOT NULL AUTO_INCREMENT ,
`date` INT NOT NULL ,
`time` INT NOT NULL ,
`comp` VARCHAR( 10 ) NOT NULL ,
`target` VARCHAR( 20 ) NOT NULL ,
`action` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
UNIQUE (`id`) ,
UNIQUE (`time`)
);


so in this case it would not allow insert records with a same time value..

is there a way other then to drop and create again table and new insert..??

any ideas??
3 REPLIES
Peter Godron
Honored Contributor

Re: simple question...mysql+unique

Hi,
have you tried:
alter table actions drop primary key;
alter table actions add primary key unique id, unique time;
amonamon
Regular Advisor

Re: simple question...mysql+unique

welll firs command passed but second did not...

any ideas????
amonamon
Regular Advisor

Re: simple question...mysql+unique

O well I dropped table and I created it again and insert data in it..