Pular para o conteúdo

Retorna a string str, com a substring que começa na posição pos e tem len caracteres de comprimento substituída pela string newstr. Retorna a string original se pos não estiver dentro do comprimento da string. Substitui o restante da string a partir da posição pos se len não estiver dentro do comprimento do restante da string. Retorna NULL se algum argumento for NULL.

func.insert(<str>, <pos>, <len>, <newstr>)
func.insert('Quadratic', 3, 4, 'What')
┌────────────────────────────────────────┐
│ func.insert('Quadratic', 3, 4, 'What') │
├────────────────────────────────────────┤
│ QuWhattic │
└────────────────────────────────────────┘
INSERT(<str>, <pos>, <len>, <newstr>)
Argumentos Descrição
<str> A string.
<pos> A posição.
<len> O comprimento.
<newstr> A nova string.

VARCHAR

SELECT INSERT('Quadratic', 3, 4, 'What');
┌───────────────────────────────────┐
│ INSERT('Quadratic', 3, 4, 'What') │
├───────────────────────────────────┤
│ QuWhattic │
└───────────────────────────────────┘
SELECT INSERT('Quadratic', -1, 4, 'What');
┌───────────────────────────────────────┐
│ INSERT('Quadratic', (- 1), 4, 'What') │
├───────────────────────────────────────┤
│ Quadratic │
└───────────────────────────────────────┘
SELECT INSERT('Quadratic', 3, 100, 'What');
┌─────────────────────────────────────┐
│ INSERT('Quadratic', 3, 100, 'What') │
├─────────────────────────────────────┤
│ QuWhat │
└─────────────────────────────────────┘
┌────────────────────────────────────────────┬────────┐
│ INSERT('123456789', number, number, 'aaa') │ number │
├────────────────────────────────────────────┼────────┤
│ 123456789 │ 0 │
│ aaa23456789 │ 1 │
│ 1aaa456789 │ 2 │
│ 12aaa6789 │ 3 │
│ 123aaa89 │ 4 │
│ 1234aaa │ 5 │
│ 12345aaa │ 6 │
│ 123456aaa │ 7 │
│ 1234567aaa │ 8 │
│ 12345678aaa │ 9 │
│ 123456789 │ 10 │
│ 123456789 │ 11 │
│ 123456789 │ 12 │
└────────────────────────────────────────────┴────────┘