Files
huachuang/sql/mysql/lms_cutpoint_time_columns.sql

12 lines
651 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 分切设备时间字段原为 varchar(25),无法容纳带微秒的 LocalDateTime(26 字符)。
-- 执行前检查历史数据,空字符串或非日期字符串需先处理。
SELECT ivt_id, create_time, update_time
FROM lms_cutpoint
WHERE (create_time IS NOT NULL AND STR_TO_DATE(create_time, '%Y-%m-%d %H:%i:%s') IS NULL)
OR (update_time IS NOT NULL AND STR_TO_DATE(update_time, '%Y-%m-%d %H:%i:%s') IS NULL);
-- 确认历史数据均为合法日期后执行,将字段类型与 Java LocalDateTime 对齐。
ALTER TABLE lms_cutpoint
MODIFY COLUMN create_time DATETIME(6) NOT NULL,
MODIFY COLUMN update_time DATETIME(6) NULL;