mysql中的事件调度程序每1分钟运行一次
IF OBJECT_ID('TempDb..#MissingList') IS NOT NULL
DROP TABLE #MissingList
CREATE TABLE #MissingList
(
SeqNo INT IDENTITY(1,1),
TABLE_NAME VARCHAR(255),
COLUMN_NAME VARCHAR(255),
MissingCount INT DEFAULT(0)
)
DECLARE @SQL NVARCHAR(MAX)
SELECT
@SQL = REPLACE(REPLACE(L.List,'
',''),';','')
FROM
(
SELECT
'
INSERT INTO #MissingList(TABLE_NAME,COLUMN_NAME,MissingCount)
SELECT TABLE_NAME = ''['+LTRIM(RTRIM(TABLE_SCHEMA))+'].['+LTRIM(RTRIM(TABLE_NAME))+']'',COLUMN_NAME = '''+LTRIM(RTRIM(COLUMN_NAME))+''',MissingCount = COUNT(1) - COUNT(['+LTRIM(RTRIM(COLUMN_NAME))+'])
FROM ['+LTRIM(RTRIM(TABLE_SCHEMA))+'].['+LTRIM(RTRIM(TABLE_NAME))+']' AS [text()]
FROM INFORMATION_SCHEMA.COLUMNS
FOR XML PATH('')
)L(LIST)
EXEC(@SQL)
SELECT
*
FROM #MissingList
答案 0 :(得分:0)
尝试一下:
SET GLOBAL event_scheduler="ON";
CREATE EVENT `user_created_this_month_schedule`
ON SCHEDULE EVERY 1 MINUTE STARTS '2018-08-31 15:35:00'
ON COMPLETION NOT PRESERVE ENABLE DO UPDATE user_data SET user_created_this_month = 0 WHERE user_data_id = 7;
SHOW EVENTS;