Skip to content

Instantly share code, notes, and snippets.

@GideonBabu
Last active November 6, 2019 15:15
Show Gist options
  • Save GideonBabu/594c829b25ff1227db8454b3ed69517a to your computer and use it in GitHub Desktop.
Save GideonBabu/594c829b25ff1227db8454b3ed69517a to your computer and use it in GitHub Desktop.
Useful MySQL Commands
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