I have several table(s) in mysql as follows :
CREATE TABLE UserMst (
UserID mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
UserName varchar(20) NOT NULL,
CreatedOn timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (UserID)
) ENGINE=InnoDB;
CREATE TABLE UserDet (
ID mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
UserID mediumint(8) unsigned DEFAULT NULL,
PRIMARY KEY (ID),
KEY FK_UserDet_UserMst_UserID (UserID),
CONSTRAINT FK_UserDet_UserMst_UserID FOREIGN KEY (UserID) REFERENCES UserMst (UserID) ON DELETE NO ACTION ON UPDATE CASCADE,
) ENGINE=InnoDB;
"UserMst" table has "UserID" as a primary key with auto increment and forginekey relation with "UserDet" with update casecade.
UserMst table has about 200000+ records and UserDet has 20000000 records in it. So now I want to reorder "UserMst" table based on "CreatedOn" field. How Do I do this without dropping relation between both tables, any idea?
Thanks