How do I remove all spaces from a field in a Postgres database in an update query?

What would be the proper syntax used to run an update query on a table to remove all spaces from the values in a column?

My table is called users and in the column fullname some values look like 'Adam Noel'. I want to remove the space so that the new value is 'AdamNoel'

I have like 30k rows


Solution 1:

update users
  set fullname = replace(fullname, ' ', '');

Solution 2:

To remove all whitespace (not just space characters) one can use:

update users set fullname = regexp_replace(fullname, '\s', '', 'g');
commit;

Solution 3:

Just use the simple code

 REPLACE('some_string', ' ', '')

or

Replace('some_string', '\s', '')

to remove any white space from the string