当前位置:网站首页>MySQL时间、时区、自动填充0的问题
MySQL时间、时区、自动填充0的问题
2022-07-06 09:17:00 【阿杆.】
数据库时间更新问题 2022/4/13
在数据库更新用户信息的时候,每次都会更新注册时间,这一波我属实是懵逼了。
起初以为是mybatis顺带把注册时间给更新了,然后排查了一下代码,没发现问题,打开mybatis日志一看,sql语句也都正确,完全没有看到更新注册时间的代码。
转念一想,没准是数据库的问题。发现注册时间这个字段勾选了根据当前时间戳更新的选项,突然懂了,原来这个选项是每次更新内容都会把这个字段给更新了。取消之后再测代码,一切正常。
数据库时区错误问题 2022/4/20
今天调试了一下某个接口,涉及到时间的,我是从Java里面获取当前时间然后转到数据库里的(其实我觉得用数据库里的 now
也可以),然后就出问题了,存进去的时间比实际时间要慢几个小时。
我仔细一想,不会是 new Timestamp(System.currentTimeMillis());
这句代码获取的时间又问题吧,果断测试了一下,发现并不是它的问题,那就肯定是数据库的问题了,但是我看数据库自动更新时间戳的那个时间又是对的。想了一下,可能是转过去的时候,时区的问题。
之前写yaml配置文件的时候,一直跟着老师写的,老师也是这么写的 jdbc:mysql://127.0.0.1:3306/blog?serverTimezone=UTC
,结果我一百度,好家伙,这个时区是世界统一时间,比北京时间慢8小时,改成 serverTimezone=Asia/Shanghai
就解决了。
数据库填充0 2022/4/20
在mysql5.6中,int等数字类型可以选择 填充0
。
填充0的意思不是说默认值为0,而是指 在显示的时候,默认向左侧填充0,即 20 会显示成 0000000020 ,当然左侧的0不一定跟我写的一样多,这里我只是打个比方。
如果不想要自动填充这么多位0,直接取消
填充零
这个选项就可以了。
边栏推荐
- Cannot change version of project facet Dynamic Web Module to 2.3.
- ESP8266使用arduino连接阿里云物联网
- 列表的使用
- uCOS-III 的特点、任务状态、启动
- ESP learning problem record
- Esp8266 connects to onenet cloud platform (mqtt) through Arduino IDE
- Oppo vooc fast charging circuit and protocol
- 基于Redis的分布式锁 以及 超详细的改进思路
- Kconfig Kbuild
- Pytorch实现简单线性回归Demo
猜你喜欢
Générateur d'identification distribué basé sur redis
几个关于指针的声明【C语言】
【ESP32学习-1】Arduino ESP32开发环境搭建
Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0
Reno7 60W超级闪充充电架构
Arduino uno R3 register writing method (1) -- pin level state change
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
Kaggle competition two Sigma connect: rental listing inquiries
Common properties of location
随机推荐
The dolphin scheduler remotely executes shell scripts through the expect command
VIM command line notes
Reno7 60W super flash charging architecture
Arduino get random number
The first simple case of GNN: Cora classification
arduino JSON数据信息解析
A possible cause and solution of "stuck" main thread of RT thread
uCOS-III 的特点、任务状态、启动
JS regular expression basic knowledge learning
Kaggle competition two Sigma connect: rental listing inquiries
Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
RuntimeError: cuDNN error: CUDNN_ STATUS_ NOT_ INITIALIZED
js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
STM32 how to locate the code segment that causes hard fault
Apprentissage automatique - - régression linéaire (sklearn)
Inline detailed explanation [C language]
C language callback function [C language]
OPPO VOOC快充电路和协议
Priority inversion and deadlock
Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0