MySQL第三课 函数以及时间相关问题


1)删除某一个时间之前的记录

delete from cs_storage_video_file where date(start_time)
问题,目前只是支持精确到日,无法支持时分秒,如下指令删除异常

de开发云主机域名lete from cs_storage_video_file where date(start_time)

2)uuid函数提供一个默认的id

3)now函数提供当前的时间,格式是datetime例子update cs_fire_control_device set temperature = 23, time = now() where id=‘123456789’
MySQL服务器版本 5.7.20,数据类型选择datetime,长度和小数点设置无法保存(通过NavCat工具访问数据库),都只能是零(MySQL版本决定),这个版本时间类型无法精确到毫秒或者微妙测试当前版本是否可以精确到毫秒
CREATE TABLE `testmilisecond` (
`tab1_id` VARCHAR(11) DEFAULT NULL,
`create` TIMESTAMP(3) NULL DEFAULT NULL,
`create2` DATETIME(3) DEFAULT NULL
) ENGINE=INNODB DEFAULT CHARSET=utf8SELECT * FROM testmilisecond;

4) 格式化datetime返回一个日期的字符串

date_format(cs_alarm_templet.start_time,’%Y-%m-%d %H:%i:%s’) as szstart_time

5) 格式化time返回一个时分秒的字符串
1. convert(cs_alarm_model_times.start_time, CHAR) as szstart_time
2. convert(cs_alarm_model_times.start_time, BINARY) as szstart_time
3. cast(cs_alarm_model_times.start_time AS CHAR) as szstart_time

相关推荐: MySQL Err 1418 的原因分析及解决方法

MySQL的有个参数log_bin_trust_function_creators,官方文档对这个参数的介绍、解释如下所示:This variable applies when binary logging is enabled. It controls wh…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 06/04 18:45
下一篇 06/04 18:45

相关推荐