首頁 > 資料庫 > mysql教程 > 如果 MySQL INSERT() 函數中的插入位置超出範圍,會發生什麼情況?

如果 MySQL INSERT() 函數中的插入位置超出範圍,會發生什麼情況?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2023-08-23 20:13:03
轉載
1389 人瀏覽過

如果 MySQL INSERT() 函数中的插入位置超出范围,会发生什么情况?

MySQL INSERT() function performs no insertion if the position of insertion is out of range. The position of insertion can be out of range in the case when we pass a negative or 0( zero) value or the value goes beyond the value of a total number of characters in an original string by 2. It can be understood with the help of the following example −

Example#query# below will perform no insertion because the position of insertion is out of range i.e. a negative value.

mysql> Select INSERT('Virat', -1,5,'Kohli');
+-------------------------------+
| INSERT('Virat', -1,5,'Kohli') |
+-------------------------------+
| Virat                         |
+-------------------------------+
1 row in set (0.00 sec)
登入後複製

下面的查詢不會執行插入操作,因為插入位置超出範圍,即0(零)。

mysql> Select INSERT('Virat', 0,5,'Kohli');
+------------------------------+
| INSERT('Virat', 0,5,'Kohli') |
+------------------------------+
| Virat                        |
+------------------------------+
1 row in set (0.00 sec)
登入後複製

下面的查詢不會執行插入操作,因為插入位置超出範圍,即超過原始字串中字元數量的值2。在下面的範例中,原始字串'Virat'有5個字符,我們給出的位置值是7,因此不會發生插入。

mysql> Select INSERT('Virat', 7,5,'Kohli');
+------------------------------+
| INSERT('Virat', 7,5,'Kohli') |
+------------------------------+
| Virat                        |
+------------------------------+
1 row in set (0.00 sec)
登入後複製

以上是如果 MySQL INSERT() 函數中的插入位置超出範圍,會發生什麼情況?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板