Last active
November 6, 2019 15:15
-
-
Save GideonBabu/594c829b25ff1227db8454b3ed69517a to your computer and use it in GitHub Desktop.
Useful MySQL Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE master_activity_log CHANGE `from_user_id` `user_id` INT(11); // change column name | |
ALTER TABLE master_activity_log DROP log_date; // remove column | |
ALTER TABLE master_activity_log ADD COLUMN log_datetime DATETIME AFTER after_save; // create new column of existing table | |
Truncate foreign key constraints table : | |
SET FOREIGN_KEY_CHECKS = 0; | |
TRUNCATE TABLE `table name`; | |
SET FOREIGN_KEY_CHECKS=1; | |
// to change the table colum datatype | |
ALTER TABLE tablename MODIFY columnname VARCHAR(20) ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment