直接上代码
${tableName} 表名
${num} 随机取的数量
-- DB2随机查询
select * from ${tableName} order by rand() fetch first ${num} rows only
-- sqlserver随机查询
SELECT top ${num} * FROM ${tableName} ORDER BY NEWID()
-- MySql随机查询
SELECT * FROM ${tableName} ORDER BY RAND() LIMIT ${num}
-- ORACLE随机查询
select * from (select *from ${tableName} order by dbms_random.value) where rownum<${num}