[root@yejr.me]> truncate table t;

# 插入1条新记录
[root@yejr.me]> insert into t select 0,rand()*1024;

# 查看 last_insert_id(), 符合预期
[root@yejr.me]> select last_insert_id();
+------------------+
| last_insert_id() |
+------------------+
| 1 |
+------------------+

[root@yejr.me]> select * from t;
+----+-----+
| id | c1 |
+----+-----+
| 1 | 730 |
+----+-----+

# 调用 last_insert_id() 时增加表达式
[root@yejr.me]> select last_insert_id(id+2) from t;
+----------------------+
| last_insert_id(id+2) |
+----------------------+
| 3 |
+----------------------+

# 再看 last_insert_id() 的值,好像“又不符合预期”了
[root@yejr.me]> select last_insert_id();
+------------------+
| last_insert_id() |
+------------------+
| 3 |
+------------------+

# 插入1条新纪录
[root@yejr.me]> insert into t select 0,rand()*1024;

# 再看 last_insert_id() 的值,好像“又回到正轨”了
[root@yejr.me]> select last_insert_id();
+------------------+
| last_insert_id(http://www.amjmh.com) |
+------------------+
| 2 |
+------------------+

[root@yejr.me]> select * from t;
+----+-----+
| id | c1 |
+----+-----+
| 1 | 730 |
| 2 | 600 |
+----+-----+
2 rows in set (0.00 sec)

最新文章

  1. STC12C5A60S2笔记3(I/O 端口)
  2. [bzoj4552][Tjoi2016][Heoi2016]排序
  3. 转载_虚拟机下LInux(终端)配置网络的方法
  4. git merge 与 rebase 的区别
  5. Find Minimum in Rotated Sorted Array
  6. vs2013的asp.net 管理
  7. EF Code First 更新数据库, 数据库迁移
  8. 如何解决WebkitBrowser使用出错“Failed to initialize activation context”
  9. codeforces 442C C. Artem and Array(有深度的模拟)
  10. 大数据技术 —— MapReduce 简介
  11. 配置OpenGL及第一个实例
  12. luogu P2580 于是他错误的点名开始了
  13. Adobe After Effects 2017-14.0安装教程
  14. oracle 行转列 列转行
  15. [Nodejs] node实现静态文件服务器
  16. dede二级导航
  17. 16 python 初学(生成器)
  18. Centos7 nginx提示错误 Access denied.
  19. Microsoft Visual Studio Community 2017 修改新建项目的默认位置
  20. C++提供的四种新式转换--const_cast dynamic_cast reinterpret_cast static_cast

热门文章

  1. ionic 提示 Error: Could not find gradle wrapper within Android SDK.
  2. 埋在 MYSQL 数据库应用中的17个关键问题!
  3. sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1091, "Can't DROP 'users_ibfk_1'; check that column/key exists") [SQL: ALTER TABLE users DROP FOREIGN KEY users_ibfk_1]
  4. 简单易用的字符串模糊匹配库Fuzzywuzzy
  5. 多线程编程-- part 4 线程间的通信
  6. 常用的商业级和免费开源Web漏洞扫描工具
  7. Ubuntu 18.04 LTS 64位Linux搭建Kubernetes 1.15.3并join子节点的完整过程
  8. Clob类型转换为String
  9. docker常用命令与容器创建
  10. 文件hash、上传,实现文件上传重复验证