{"id":559,"date":"2010-12-04T10:41:31","date_gmt":"2010-12-04T10:41:31","guid":{"rendered":""},"modified":"2010-12-04T10:41:31","modified_gmt":"2010-12-04T10:41:31","slug":"559","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=559","title":{"rendered":"\u5728MySQL\u4e2d\u968f\u673a\u751f\u6210\u56fa\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5"},"content":{"rendered":"<p>\u5728MySQL\u4e2d\u6709\u65f6\u9700\u8981\u968f\u673a\u751f\u6210\u6570\u5b57\u6216\u5b57\u7b26\u4e32\uff0c\u968f\u673a\u751f\u4ea7\u6570\u5b57\u53ef\u76f4\u63a5\u4f7f\u7528rand()\u51fd\u6570\uff0c\u4f46\u662f\u8981\u968f\u673a\u751f\u6210\u5b57\u7b26\u4e32\u5c31\u6bd4\u8f83\u9ebb\u70e6\u3002<\/p>\n<p>\u8981\u968f\u673a\u751f\u6210\u5b57\u7b26\u4e32\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>\u5728MySQL\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u968f\u673a\u4e32\u7684\u65b9\u6cd5\uff0c\u7136\u540e\u518dSQL\u8bed\u53e5\u4e2d\u8c03\u7528\u6b64\u65b9\u6cd5\u3002<\/p>\n<p>\u968f\u673a\u4e32\u51fd\u6570\u5b9a\u4e49\u65b9\u6cd5\uff1a <\/p>\n<p><code><br \/>Create DEFINER=`root`@`localhost` FUNCTION `rand_string`(n INT) RETURNS varchar(255) CHARSET latin1<br \/>BEGIN<br \/>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE chars_str varchar(100) DEFAULT 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';<br \/>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE return_str varchar(255) DEFAULT '';<br \/>&nbsp;&nbsp;&nbsp;&nbsp;DECLARE i INT DEFAULT 0;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;WHILE i &lt; n DO<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET return_str = concat(return_str,substring(chars_str , FLOOR(1 + RAND()*62 ),1));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET i = i +1;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;END WHILE;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;RETURN return_str;<br \/>END;<br \/><\/code><\/p>\n<p>\u4f7f\u7528\u968f\u673a\u4e32\u51fd\u6570\u65b9\u6cd5\u793a\u4f8b\uff1a<\/p>\n<p>Update demotable SET demoname=rand_string(32) Where id&gt;23<\/p>\n<p>\u76f4\u63a5\u6267\u884c\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728MySQL\u4e2d\u6709\u65f6\u9700\u8981\u968f\u673a\u751f\u6210\u6570\u5b57\u6216\u5b57\u7b26\u4e32\uff0c\u968f\u673a\u751f\u4ea7\u6570\u5b57\u53ef\u76f4\u63a5\u4f7f\u7528r&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-559","post","type-post","status-publish","format-standard","hentry","category-DB"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=559"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/559\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}