Database - usage of overlay function in postgresql

Function: The overlay function in postgresql is used to replace characters at a specific position in a string field

语法:overlay(string1 placing string2 from int for int) 

string1: the name of the field to be replaced;

string2: the character to replace;

The first int: the starting position of the replacement ( note: the starting position of this method should start from 1 );

The second int: the length to be replaced

Usage: For example, if there is a field whose type is a string, and then the value is "SLP00 0 2336306", the corresponding field name in the table is slip_no, and you want to change it to "SLP00 1 2336306"

The sql statement can be written as select overlay(slip_no placing '1' from 6 for 1) as slip_no from table (table name)

 

Guess you like

Origin blog.csdn.net/dazhanglao/article/details/104919398