sql随机日期
如果靠插入随机数保证不重复的话,我觉得做起来还是有点麻烦,你要设置
唯一约束才可以的.
你可以某个时间为基准点,分别加上
1分钟,2分钟,3分钟,这样来说的话,我觉得还是比较快的.
⑵ sql 日期随机赋值问题
select to_date('20090815','yyyymmdd')+mod(trunc(dbms_random.value()*100),11) from al;
⑶ 使用sql语句插入随机时间
时间的大小做一个if判断
时间函数
getdate()
datediff()
dateadd()
⑷ SQL 将日期的秒钟随机语句怎么写
create table #(mark int)
go
declare @i int
set @i=0
while @i<=59
begin
insert into # values(@i)
set @i=@i+1
end
go
--随机数NewID办法
declare @myRand int
select top 1 @myRand=mark from # order by newid()
select @myRand
go
--Rand()办法(不过只是1-59)
declare @myRand int
select @myRand=cast(CEILING(rand()*59) as int)
select @myRand
--还是建议第一种
⑸ sql怎么生成某一个时段内的随机时间戳
SQLSERVER : select floor(rand()*(AB-AA))+AA
含义是,两个时间分别为 A 和 B, A < B ,将两个时间转换为时间戳 AA,AB?
SET newstime=FLOOR(UNIX_TIMESTAMP()-1000 - RAND() * (3186400)) where id<500
FLOOR(UNIX_TIMESTAMP()-1000 - RAND() * (3186400)) ,这句语法有错误吗?
提问问题是:怎么生成某一个时段内的随机时间戳。 比如 3月内,4月内
⑹ MySql数据库SQL命令指定时间范围批量递增随机修改文章发布时间
CREATE TABLE test_random_time ( id int, newstime datetime); INSERT INTO test_random_timeSELECT 1, '2012-11-13 01:00:00' UNION ALLSELECT 2, '2012-11-13 02:00:00' UNION ALLSELECT 3, '2012-11-13 03:00:00' UNION ALLSELECT 4, '2012-11-13 04:00:00' UNION ALLSELECT 5, '2012-11-13 05:00:00'; -- 20点至23点。-- 区间=3小时=180分钟=10800秒-- 下面更新时间 = '2012-11-13 20:00:00' 之后的 随机秒数。(区间在 1- 10800 之间)UPDATE test_random_timeSET newstime = DATE_ADD('2012-11-13 20:00:00', INTERVAL FLOOR(1 + (RAND() * 10800)) SECOND )WHERE DATE(newstime) = '2012-11-13'; -- 数据核对.mysql> SELECT * FROM test_random_time;+------+---------------------+| id | newstime |+------+---------------------+| 1 | 2012-11-13 22:25:14 || 2 | 2012-11-13 22:41:16 || 3 | 2012-11-13 20:10:35 || 4 | 2012-11-13 21:49:08 || 5 | 2012-11-13 22:33:55 |+------+---------------------+5 rows in set (0.00 sec)
⑺ C# 后台如何向SQL数据库中插入一定时间范围内的随机日期值,到日就可以!!
两种方式,一种是通过程序在后台写SQL来做。譬如“insert into tab(colTime) Values('时间') ”
另一种,直接将表的时间字段默认值改为 getdate()
⑻ sql表更新为随机数据取时间范围
update table set i=dateadd(minute, 25*rand()-datepart(minute,i), i) where 条件
⑼ SQL.求一个随机产生时间的函数
--建立过程
create procere gettime
@begintime varchar(5),@EndTime varchar(5),@randtime varchar(5) output
as
set @randtime=(SELECT substring(convert(varchar,convert(datetime,100/RAND(),120),120),12,5) )
while @randtime<=@begintime or @randtime>=@endtime
set @randtime=(SELECT substring(convert(varchar,convert(datetime,100/RAND(),120),120),12,5) )
go
--执行示例
declare @outtime varchar(5)
exec hygettime '05:00','20:00',@outtime output
select @outtime
⑽ MYSQL执行sql语句,批量更改为指定时间段的随机时间
1、首先打开mysql,连接一个数据库,点击上方的【查询】按钮,再点击【新建查询】,如图所示。