「MariaDB」insert関数で指定文字を置き換える

環境
Windows 10 64 bit
MariaDB 10.6.4
書式
INSERT(targetstr,pos,len,newstr)
targetstr:対象となる文字列
pos:指定位置
len:指定した文字数
newstr:新しい文字列
INSERT 関数は引数に指定した文字列の中に含まれる指定の位置から指定の長さ分を別の文字列に置き換えます。

使用例1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> select insert('study',3,6,'arkgame') res;
+-----------+
| res |
+-----------+
| starkgame |
+-----------+
1 row in set (0.000 sec)
MariaDB [(none)]> select insert('study',3,6,'arkgame') res; +-----------+ | res | +-----------+ | starkgame | +-----------+ 1 row in set (0.000 sec)
MariaDB [(none)]> select insert('study',3,6,'arkgame') res;
+-----------+
| res       |
+-----------+
| starkgame |
+-----------+
1 row in set (0.000 sec)

使用例2
マルチバイト文字を使用する場合、次のように実行します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> select insert('東京都品川区五反田',7,3,'大井町') res;
+--------------------+
| res |
+--------------------+
| 東京都品川区大井町 |
+--------------------+
1 row in set (0.000 sec)
MariaDB [(none)]> select insert('東京都品川区五反田',7,3,'大井町') res; +--------------------+ | res | +--------------------+ | 東京都品川区大井町 | +--------------------+ 1 row in set (0.000 sec)
MariaDB [(none)]> select insert('東京都品川区五反田',7,3,'大井町') res;
+--------------------+
| res                |
+--------------------+
| 東京都品川区大井町 |
+--------------------+
1 row in set (0.000 sec)

 

MariaDB

Posted by arkgame