如何在更新查询中从Postgres数据库的字段中删除所有空格? [英] How do I remove all spaces from a field in a Postgres database in an update query?

查看:108
本文介绍了如何在更新查询中从Postgres数据库的字段中删除所有空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在表上运行更新查询以从列中的值中删除所有空格的正确语法是什么?

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?

我的表称为用户,并在全名列中,某些值类似于'Adam Noel'。我要删除空格,以便新值是'AdamNoel'

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'

我有3万行

推荐答案

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

这篇关于如何在更新查询中从Postgres数据库的字段中删除所有空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆