生成随机的时间的SQL
SELECT make_time(floor((random() * 12))::int, floor((random() * 60))::int, floor((random() * 60))::int) AS rand_time;
生成随机的日期的SQL
SELECT current_date - floor((random() * 25))::int
生成随机的年月日时分秒的SQL
SELECT concat(current_date - floor((random() * 25))::int,' ',make_time(floor((random() * 12))::int, floor((random() * 60))::int, floor((random() * 60))::int))
这篇博客分享了如何使用SQL语句生成随机的时间、日期和年月日时分秒。通过示例代码,展示了如何利用函数和随机数生成不同格式的时间数据,对于数据库测试和数据填充非常实用。
693

被折叠的 条评论
为什么被折叠?



