登录
首页 >  数据库 >  MySQL

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

来源:tutorialspoint

时间:2023-08-24 23:36:25 137浏览 收藏

大家好,我们又见面了啊~本文《如果 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

The 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() 函数中的插入位置超出范围,会发生什么情况?》文章吧,也可关注golang学习网公众号了解相关技术文章。

声明:本文转载于:tutorialspoint 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>