更新时间:

#mysql 小技巧

  • insert into table select .. from...
  • insert ignore into table....
  • replace into table ...
  • create table ban_ip as select uid from ....

//这个完事后自己手动加上索引

  • create table qinbin3 like elex1; 会自动加索引,无数据

#总结:create table as比insert into select具有更好的性能越提升4倍以上;

原理分析:create table as是ddl语句,insert into select是dml语句,insert into select每一条记录的时候都会产生undo和redo,整个过程相比create table as产生的redo和undo相当多,因此整个过程会慢也是正常的;但是create table as使用的前提是目标表的结构不存在才能使用;
当有大量数据的时候不推荐使用Insert into as,因为该语句的插入的效率很慢;

  • update 连表更新

UPDATE Track
INNER JOIN MV
ON Track.trkid=MV.mvid
SET Track.is_show=MV.is_show
WHERE trkid