Postgresql – How to change the mount point for a column in postgresql table

postgresql

This is my scenario

I have a table t with following columns

id  int
link  varchar(500)
name  varchar(20)
sal   text

In the link column we will store the location for the pdf files(mount point)

Ex: link /ABC/ABC_DATA/Mydata/Test/a1.pdf

there will be one link for every id

Application Users have changed their pdf file location from "/ABC/ABC_DATA/Test/a1.pdf" to "/CBF/CBF_DATA/Documents/Test_DATA/a1.pdf"

Now how can i update the table with new location for all the rows. Table contains nearly 10,000 rows

Note:id and link are related every id contains unique link.

Best Answer

Maybe I'm missing something, but it sounds as if that is a simple case of replacing the value:

update the_table
   set link = replace(link, '/ABC/ABC_DATA/Test/', '/CBF/CBF_DATA/Documents/Test_DATA/');