update cdsgus set Name=REPLACE(Name, CHAR(13) + CHAR(十), '') 速度好慢呀,有办法优化吗

update cdsgus set Name=REPLACE(Name, CHAR(13) + CHAR(10), '') 速度好慢呀,有办法优化吗?
update cdsgus set Name=REPLACE(Name, CHAR(13) + CHAR(10), '') 速度好慢呀,有办法优化吗?


估计好多人都知道,我就不多说了,我只是想把里面的“回车、换行、制表”清理掉而已。

执行一次要花40多分钟。真是扯蛋呀。
------解决方案--------------------
你的表里数据量是多大呢?

我觉得是否可以这样:

 select REPLACE(Name, CHAR(13) + CHAR(10), '')  as name, 其他字段 into new_table
 from cdsgus

然后:

truncate table cdsgus

最后:

insert into cdsgus
select *
from new_table
------解决方案--------------------
引用:
Quote: 引用:

你的表里数据量是多大呢?

我觉得是否可以这样:

 select REPLACE(Name, CHAR(13) + CHAR(10), '')  as name, 其他字段 into new_table
 from cdsgus

然后:

truncate table cdsgus

最后:

insert into cdsgus
select *
from new_table


2千万多点。


那就是数据量相对较大,而你的这个操作是全表扫描,所以才会慢的。

这种情况建议用上面的写法,先去除 多余字符,然后插入到新表,再把原表truncate后,最后再导入数据