有用的mysql 语句 - fubd/blowfish GitHub Wiki

插入100w数据

DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `batchInsert2`(in args int)
begin
declare i int default 1;
start transaction;

while i <= args do
  insert into user(`nickname`) value(concat("penguin-",i));
  set i = i+ 1;
end while;

commit;
end;;
DELIMITER ;

call batchInsert2(1000000)

设置时间戳

ALTER TABLE user CHANGE updated_at updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
ALTER TABLE user MODIFY created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL