此博客为平安老铁而写!
//表存在则执行删除表SQL
DECLARE
numbe NUMBER;
BEGIN
SELECT COUNT(1)
INTO numbe
FROM USER_TABLES
WHERE TABLE_NAME = UPPER(#{tableName});
IF numbe > 0 THEN
EXECUTE IMMEDIATE 'DROP TABLE ' || '#{tableName}';
END IF;
END;
//创建表
CREATE TABLE #{tableName}(
);
-- MySql 生成连续时间 连续ID
SELECT
date
FROM
(
SELECT
'2021-07-01' + INTERVAL ( @num ) DAY AS date,
@num := @num + 1 num
FROM
(
SELECT
rownum
FROM
(
SELECT
@rownum := @rownum + 1 AS rownum
FROM
( SELECT @rownum := 0 ) r,
( SELECT * FROM system_log ) info
) t
WHERE
t.rownum <= ( TIMESTAMPDIFF( DAY, '2021-07-01', DATE_FORMAT( NOW(), '%Y-%m-%d %H:%i:%S' )) + 1 )
) u,(
SELECT
@num := 0
) t
) lsb