In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to replace a character in a field by mysql and mongodb". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to replace a character in a field by mysql and mongodb.
1. Replace the key characters in the mysql field (replace the zjy.zyzhjyy.cn domain name with zjy.zyjyxx.com).
Note: please make a good data backup before operation.
Update cloud_push_log set result_path = replace (result_path, 'zjy.zyzhjyy.cn','zjy.zyjyxx.com')
Cloud_push_log: specify a table name
Result_path: field name
two。 Replace a string in the mongodb field (replace the zjy.zyjyxx.com character with zjy.zyzhjyy.cn).
Note: please make a good data backup before operation.
Db.getCollection ('eventArgs') .find ({' contextFileHost': {'$ne':null}, 'contextFileHost':/\ .zjy\ .zyjxx\ .com /}). ForEach (function (item) {var tmp = String (item.contextFileHost) if (tmp = = null) {print (item.contextFileHost)} else {tmp = tmp.replace (/\ .zjy\ .zyjxx\ .com / g) "\ .zjy\ .zyzhjyy\ .cn") } item.contextFileHost = tmp; db.getCollection ('eventArgs') .save (item); print ("update to" + item.contextFileHost)})
EventArgs: specify tabl
ContextFileHost: field name
(2)。 Nested modification characters (replace zjy.zyjyxx.com domain name with zjy.zyzhjyy.cn)
Db.getCollection ('eventArgs') .find ({' files.origin': {'$ne':null}) 'files.origin':/\ .zjy\ .zyjyxx\ .com /}) .forEach (function (item) {var tmp = String (item.files.origin) if (tmp = = null) {print (item.files.origin)} else {tmp = tmp.replace (/\ .zjy\ .zyjxx\ .com / g, "\ .zjy\ .zyzhjyy\ .cn") } item.files.origin= tmp; db.getCollection ('eventArgs') .save (item); print ("update to" + item.files.origin)})
EventArgs: table name
Files.origin:files is the first-level field name and origin is the second-level field name.
(3) with array batch update data in the field (replace the zjy.zyjyxx.com domain name with zjy.zyzhjyy.cn)
Note: please make a good data backup before operation.
Db.getCollection ('convert_state_copy0515-1'). Find ({'executeArgs.source':new RegExp (". * zjy.zyjyxx.com.*")}) .forEach (function (item) {var executeArgs = item [' executeArgs']; for (var i in executeArgs) {var source = executeArgs [I] ['source']) If (null! = source & & String (source) .search ('zjy.zyjyxx.com') >-1) {executeArgs [I] [' source'] = source.replace ('zjy.zyjyxx.com',' zjy.zyzhjyy.cn');} var callback = executeArgs [I] ['callback'] If (null! = callback) {var callback_url = executeArgs [I] ['callback'] [' url'] If (null! = callback_url & & String (callback_url) .search ('zjy.zyjyxx.com') >-1) {executeArgs [I] [' callback'] ['url'] = callback_url.replace (' zjy.zyjyxx.com', 'zjy.zyzhjyy.cn') }} var upload = executeArgs [I] ['upload']; if (null! = upload) {var upload_url = executeArgs [I] [' upload'] ['url'] If (null! = upload_url & & String (upload_url) .search ('zjy.zyjyxx.com') >-1) {executeArgs [I] [' upload'] ['url'] = upload_url.replace (' zjy.zyjyxx.com', 'zjy.zyzhjyy.cn') } db.getCollection ('convert_state_copy0515-1') .update ({"_ id": item ['_ id']}, {$set: {"executeArgs": executeArgs, "exec": 1}});})
Convert_state_copy0515-1: table name
ExecuteArgs.source: field name
Source,callback,upload: field name
At this point, I believe you have a deeper understanding of "how to replace a character in a field by mysql and mongodb". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.