我在MySQL中有一个表customers_info,其中有一列“address”。出于隐私的原因,我想用随机文本(任何文本,例如xwdjduhyrmdz)替换所有行中的“address”值。我找到了这个SQL并在phpmyadmin上尝试了一下,但是没有成功。
customers_info
xwdjduhyrmdz
UPDATE customer_info SET address = LEFT(REPLACE(CAST(NEWID() AS CHAR(40)), '-', ''), @Characters)
我该怎么做呢?
nnvyjq4y1#
此查询会将address列的所有行更新为6个字符的随机字符串
address
UPDATE `yourTable` SET `address` = CONCAT( SUBSTRING('abcdefghijklmnopqrstuvwxyz', FLOOR(RAND()*26) + 1, 1), SUBSTRING('abcdefghijklmnopqrstuvwxyz', FLOOR(RAND()*26) + 1, 1), SUBSTRING('abcdefghijklmnopqrstuvwxyz', FLOOR(RAND()*26) + 1, 1), SUBSTRING('abcdefghijklmnopqrstuvwxyz', FLOOR(RAND()*26) + 1, 1), SUBSTRING('abcdefghijklmnopqrstuvwxyz', FLOOR(RAND()*26) + 1, 1), SUBSTRING('abcdefghijklmnopqrstuvwxyz', FLOOR(RAND()*26) + 1, 1) );
1条答案
按热度按时间nnvyjq4y1#
此查询会将
address
列的所有行更新为6个字符的随机字符串