I won’t talk more nonsense. Let’s look at the code directly~
UPDATE table set name = trim(name);// Used to delete spaces before and after data
UPDATE table set name = rtrim(name);// Used to delete the space before the data
UPDATE table set name = ltrim(name);// Used to delete the space after the data
UPDATE table set name = REPLACE(name,' ','');// Used to delete spaces in data
Update table set name = replace (name, Chr (10), '' // replace newline character
Update table set name = replace (name, Chr (13), '' // replace carriage return character
Supplement: PostgreSQL queries the line feed and carriage return characters:
1. Sometimes, the business makes mistakes due to carriage return and line feed,
The first step is to query the data of carriage return character and line feed character:
--Query with Chr (13) and Chr (10)
Select * from data table name where "field" like '%' ||||chr (13) ||||||||||||||||||||||||||||||||;
--In fact, data can be queried by querying Chr (13) and Chr (10)
Select * from data table name where "field" like '%' 𞓜chr (13) |'%';
Select * from data table name where "field" like '%' 𞓜chr (10) | '%';
--Chr (int) converts numbers into characters; For example, select Chr (65); A
For those who are confused about carriage return and line feed, you can briefly understand:
Carriage return \ r originally means that the cursor returns to the beginning of the line. The English return of R can be written as Cr, that is, carriage return
Line feed \ nthe original meaning is the next line of the cursor (not necessarily to the beginning of the next line), the English newline of N, and the control character can be written as LF, that is, line feed
Symbol ASCII meaning
\N 10 line feed NL
\R 13 enter Cr
The above is my personal experience. I hope I can give you a reference, and I hope you can support developpaer. If there are mistakes or not fully considered, please don’t hesitate to comment.