I have following table in database AND I need to alter it to below mentioned schema. Initially I was drop the current database and creating new one using the create but I am not supposed to do that and use ALTER but am not sure as to how can I use ALTER to add primary key and other constraints. Any Suggestions !!!
Code
Current:
CREATE TABLE `details` (
`KEY` varchar(255) NOT NULL,
`ID` bigint(20) NOT NULL,
`CODE` varchar(255) NOT NULL,
`C_ID` bigint(20) NOT NULL,
`C_CODE` varchar(64) NOT NULL,
`CCODE` varchar(255) NOT NULL,
`TCODE` varchar(255) NOT NULL,
`LCODE` varchar(255) NOT NULL,
`CAMCODE` varchar(255) NOT NULL,
`OFCODE` varchar(255) NOT NULL,
`OFNAME` varchar(255) NOT NULL,
`PRIORITY` bigint(20) NOT NULL,
`STDATE` datetime NOT NULL,
`ENDATE` datetime NOT NULL,
`INT` varchar(255) NOT NULL,
`PHONE` varchar(255) NOT NULL,
`TV` varchar(255) NOT NULL,
`MTV` varchar(255) NOT NULL,
`TYPE` varchar(255) NOT NULL,
`CREATED` datetime NOT NULL,
`MAIN` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Desired:
CREATE TABLE `details` (
`id` bigint(20) NOT NULL,
`code` varchar(255) NOT NULL,
`cid` bigint(20) NOT NULL,
`ccode` varchar(64) NOT NULL,
`c_code` varchar(255) NOT NULL,
`tcode` varchar(255) NOT NULL,
`lcode` varchar(255) NOT NULL,
`camcode` varchar(255) NOT NULL,
`ofcode` varchar(255) NOT NULL,
`ofname` varchar(255) NOT NULL,
`priority` bigint(20) NOT NULL,
`stdate` datetime NOT NULL,
`enddate` datetime NOT NULL,
`list` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`created` datetime NOT NULL,
`date` datetime NOT NULL,
`ofshn` int(20) NOT NULL,
`ofcl` int(20) NOT NULL,
`ofr` int(20) NOT NULL,
PRIMARY KEY (`code`,`ccode`,`list`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Thanks !!!