我需要更新我的数据库中的表。为简单起见,我们假设表的名称是tab
并且它有 2 列:id (PRIMARY KEY, NOT NULL)
和col (UNIQUE VARCHAR(300))
。我需要以这种方式更新表:
id col
----------------------------------------------------
1 'One two three'
2 'One twothree'
3 'One two three'
4 'Remove white spaces'
5 'Something'
6 'Remove whitespaces '
至:
id col
----------------------------------------------------
1 'Onetwothree'
2 'Removewhitespaces'
3 'Something'
Id
更新后的行数和顺序并不重要,可以不同。我使用 PostgreSQL。一些列是外键。这就是为什么放弃UNIQUE
约束col
会很麻烦。