Modify, add, or delete fields using SQL Replace statements in batches.
SQL replacement statement. You can use this command to replace the content of a field in the whole batch, or add or remove characters to or from the original field content in batches.
Command General Solution: update table name set the field name to be replaced in this table = REPLACE (the Field name to be replaced in this table, 'original content', 'new content ')
For example, UPDATE Whir_ProductRelese SET ReleseName = REPLACE (ReleseName, 'HTTP: // www.maidq.com ', 'HTTP: // maidq.com ')
Example:
1) In the backupfile table url field content for the http://www.maidq.com of all characters to http://maidq.com.
update backupfile set url=REPLACE(url,'http://www.maidq.com','http://maidq.com')
2) Add the field content according to the conditions. For example, add tmp to the content of the logical_name field of the record with file_number = 1, and end to the record.
update backupfile set logical_name=REPLACE(logical_name,logical_name,'tmp'+logical_name+' end ') where file_number=1
3) Remove the first two characters of the specified Record Based on the condition.
update backupfile set logical_name=REPLACE(logical_name,logical_name,SUBSTRING(logical_name,3,len(logical_name)-2)) where file_number=1
4) Remove the four characters after the specified Record Based on the condition.
update backupfile set logical_name=REPLACE(logical_name,logical_name,SUBSTRING(logical_name,1,len(logical_name)-4)) where file_number=2
If it is unclear, you can use the select statement to verify whether the desired effect is achieved and then replace it:
Select replace (REPLACE field, 'original content', 'new content') from table name; update table name set REPLACE field = (REPLACE field, 'original content ', 'New content '))
The above section describes how to modify, add, and delete fields using SQL Replace statements in batches. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!