当前位置:网站首页>MySQL時間、時區、自動填充0的問題
MySQL時間、時區、自動填充0的問題
2022-07-06 12:16: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,直接取消
填充零這個選項就可以了。
边栏推荐
- Basic operations of databases and tables ----- classification of data
- arduino获取随机数
- Working principle of genius telephone watch Z3
- ESP8266通过Arduino IDE连接Onenet云平台(MQTT)
- Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
- 优先级反转与死锁
- The dolphin scheduler remotely executes shell scripts through the expect command
- Gallery's image browsing and component learning
- ES6 grammar summary -- Part I (basic)
- JS 函数提升和var变量的声明提升
猜你喜欢

E-commerce data analysis -- User Behavior Analysis

Understanding of AMBA, AHB, APB and Axi

RT thread API reference manual

Reno7 60W超级闪充充电架构

E-commerce data analysis -- salary prediction (linear regression)

Classification, understanding and application of common methods of JS array

【ESP32学习-2】esp32地址映射
![Several declarations about pointers [C language]](/img/9b/ace0abbd1956123a945a98680b1e86.png)
Several declarations about pointers [C language]

Basic knowledge of lithium battery

RT-Thread的main线程“卡死”的一种可能原因及解决方案
随机推荐
open-mmlab labelImg mmdetection
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
Togglebutton realizes the effect of switching lights
PyTorch四种常用优化器测试
[esp32 learning-2] esp32 address mapping
AMBA、AHB、APB、AXI的理解
ES6语法总结--上篇(基础篇)
History object
Arduino JSON data information parsing
Learning notes of JS variable scope and function
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
Redis based distributed locks and ultra detailed improvement ideas
Dead loop in FreeRTOS task function
数据分析之缺失值填充(重点讲解多重插值法Miceforest)
Mysql database interview questions
arduino获取随机数
Gallery's image browsing and component learning
RuntimeError: cuDNN error: CUDNN_ STATUS_ NOT_ INITIALIZED
E-commerce data analysis -- User Behavior Analysis
Machine learning -- decision tree (sklearn)