当前位置:Gxlcms >
数据库问题 >
SqlServer+Topshelf+Quartznet做集群,定时任务分布式处理
SqlServer+Topshelf+Quartznet做集群,定时任务分布式处理
时间:2021-07-01 10:21:17
帮助过:8人阅读
USE 数据库名
2 GO
3
4 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[FK_QRTZ_TRIGGERS_QRTZ_JOB_DETAILS]‘)
AND OBJECTPROPERTY(id, N
‘ISFOREIGNKEY‘)
= 1)
5 ALTER TABLE [dbo].
[QRTZ_TRIGGERS] DROP CONSTRAINT FK_QRTZ_TRIGGERS_QRTZ_JOB_DETAILS
6 GO
7
8 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[FK_QRTZ_CRON_TRIGGERS_QRTZ_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISFOREIGNKEY‘)
= 1)
9 ALTER TABLE [dbo].
[QRTZ_CRON_TRIGGERS] DROP CONSTRAINT FK_QRTZ_CRON_TRIGGERS_QRTZ_TRIGGERS
10 GO
11
12 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[FK_QRTZ_SIMPLE_TRIGGERS_QRTZ_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISFOREIGNKEY‘)
= 1)
13 ALTER TABLE [dbo].
[QRTZ_SIMPLE_TRIGGERS] DROP CONSTRAINT FK_QRTZ_SIMPLE_TRIGGERS_QRTZ_TRIGGERS
14 GO
15
16 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[FK_QRTZ_SIMPROP_TRIGGERS_QRTZ_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISFOREIGNKEY‘)
= 1)
17 ALTER TABLE [dbo].
[QRTZ_SIMPROP_TRIGGERS] DROP CONSTRAINT FK_QRTZ_SIMPROP_TRIGGERS_QRTZ_TRIGGERS
18 GO
19
20 IF EXISTS (
SELECT * FROM sys.foreign_keys
WHERE object_id = OBJECT_ID(N
‘[dbo].[FK_QRTZ_JOB_LISTENERS_QRTZ_JOB_DETAILS]‘)
AND parent_object_id
= OBJECT_ID(N
‘[dbo].[QRTZ_JOB_LISTENERS]‘))
21 ALTER TABLE [dbo].
[QRTZ_JOB_LISTENERS] DROP CONSTRAINT [FK_QRTZ_JOB_LISTENERS_QRTZ_JOB_DETAILS]
22
23 IF EXISTS (
SELECT * FROM sys.foreign_keys
WHERE object_id = OBJECT_ID(N
‘[dbo].[FK_QRTZ_TRIGGER_LISTENERS_QRTZ_TRIGGERS]‘)
AND parent_object_id
= OBJECT_ID(N
‘[dbo].[QRTZ_TRIGGER_LISTENERS]‘))
24 ALTER TABLE [dbo].
[QRTZ_TRIGGER_LISTENERS] DROP CONSTRAINT [FK_QRTZ_TRIGGER_LISTENERS_QRTZ_TRIGGERS]
25
26
27 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_CALENDARS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
28 DROP TABLE [dbo].
[QRTZ_CALENDARS]
29 GO
30
31 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_CRON_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
32 DROP TABLE [dbo].
[QRTZ_CRON_TRIGGERS]
33 GO
34
35 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_BLOB_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
36 DROP TABLE [dbo].
[QRTZ_BLOB_TRIGGERS]
37 GO
38
39 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_FIRED_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
40 DROP TABLE [dbo].
[QRTZ_FIRED_TRIGGERS]
41 GO
42
43 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_PAUSED_TRIGGER_GRPS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
44 DROP TABLE [dbo].
[QRTZ_PAUSED_TRIGGER_GRPS]
45 GO
46
47 IF EXISTS (
SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N
‘[dbo].[QRTZ_JOB_LISTENERS]‘)
AND type
in (N
‘U‘))
48 DROP TABLE [dbo].
[QRTZ_JOB_LISTENERS]
49
50 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_SCHEDULER_STATE]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
51 DROP TABLE [dbo].
[QRTZ_SCHEDULER_STATE]
52 GO
53
54 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_LOCKS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
55 DROP TABLE [dbo].
[QRTZ_LOCKS]
56 GO
57 IF EXISTS (
SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N
‘[dbo].[QRTZ_TRIGGER_LISTENERS]‘)
AND type
in (N
‘U‘))
58 DROP TABLE [dbo].
[QRTZ_TRIGGER_LISTENERS]
59
60
61 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_JOB_DETAILS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
62 DROP TABLE [dbo].
[QRTZ_JOB_DETAILS]
63 GO
64
65 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_SIMPLE_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
66 DROP TABLE [dbo].
[QRTZ_SIMPLE_TRIGGERS]
67 GO
68
69 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_SIMPROP_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
70 DROP TABLE [dbo].QRTZ_SIMPROP_TRIGGERS
71 GO
72
73 IF EXISTS (
SELECT * FROM dbo.sysobjects
WHERE id
= OBJECT_ID(N
‘[dbo].[QRTZ_TRIGGERS]‘)
AND OBJECTPROPERTY(id, N
‘ISUSERTABLE‘)
= 1)
74 DROP TABLE [dbo].
[QRTZ_TRIGGERS]
75 GO
76
77 CREATE TABLE [dbo].
[QRTZ_CALENDARS] (
78 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
79 [CALENDAR_NAME] [NVARCHAR] (
200)
NOT NULL ,
80 [CALENDAR] [IMAGE] NOT NULL
81 )
82 GO
83
84 CREATE TABLE [dbo].
[QRTZ_CRON_TRIGGERS] (
85 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
86 [TRIGGER_NAME] [NVARCHAR] (
150)
NOT NULL ,
87 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL ,
88 [CRON_EXPRESSION] [NVARCHAR] (
120)
NOT NULL ,
89 [TIME_ZONE_ID] [NVARCHAR] (
80)
90 )
91 GO
92
93 CREATE TABLE [dbo].
[QRTZ_FIRED_TRIGGERS] (
94 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
95 [ENTRY_ID] [NVARCHAR] (
140)
NOT NULL ,
96 [TRIGGER_NAME] [NVARCHAR] (
150)
NOT NULL ,
97 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL ,
98 [INSTANCE_NAME] [NVARCHAR] (
200)
NOT NULL ,
99 [FIRED_TIME] [BIGINT] NOT NULL ,
100 [SCHED_TIME] [BIGINT] NOT NULL ,
101 [PRIORITY] [INTEGER] NOT NULL ,
102 [STATE] [NVARCHAR] (
16)
NOT NULL,
103 [JOB_NAME] [NVARCHAR] (
150)
NULL ,
104 [JOB_GROUP] [NVARCHAR] (
150)
NULL ,
105 [IS_NONCONCURRENT] BIT NULL ,
106 [REQUESTS_RECOVERY] BIT NULL
107 )
108 GO
109
110 CREATE TABLE [dbo].
[QRTZ_PAUSED_TRIGGER_GRPS] (
111 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
112 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL
113 )
114 GO
115
116 CREATE TABLE [dbo].
[QRTZ_SCHEDULER_STATE] (
117 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
118 [INSTANCE_NAME] [NVARCHAR] (
200)
NOT NULL ,
119 [LAST_CHECKIN_TIME] [BIGINT] NOT NULL ,
120 [CHECKIN_INTERVAL] [BIGINT] NOT NULL
121 )
122 GO
123
124 CREATE TABLE [dbo].
[QRTZ_LOCKS] (
125 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
126 [LOCK_NAME] [NVARCHAR] (
40)
NOT NULL
127 )
128 GO
129
130 CREATE TABLE [dbo].
[QRTZ_JOB_DETAILS] (
131 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
132 [JOB_NAME] [NVARCHAR] (
150)
NOT NULL ,
133 [JOB_GROUP] [NVARCHAR] (
150)
NOT NULL ,
134 [DESCRIPTION] [NVARCHAR] (
250)
NULL ,
135 [JOB_CLASS_NAME] [NVARCHAR] (
250)
NOT NULL ,
136 [IS_DURABLE] BIT NOT NULL ,
137 [IS_NONCONCURRENT] BIT NOT NULL ,
138 [IS_UPDATE_DATA] BIT NOT NULL ,
139 [REQUESTS_RECOVERY] BIT NOT NULL ,
140 [JOB_DATA] [IMAGE] NULL
141 )
142 GO
143
144 CREATE TABLE [dbo].
[QRTZ_SIMPLE_TRIGGERS] (
145 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
146 [TRIGGER_NAME] [NVARCHAR] (
150)
NOT NULL ,
147 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL ,
148 [REPEAT_COUNT] [INTEGER] NOT NULL ,
149 [REPEAT_INTERVAL] [BIGINT] NOT NULL ,
150 [TIMES_TRIGGERED] [INTEGER] NOT NULL
151 )
152 GO
153
154 CREATE TABLE [dbo].
[QRTZ_SIMPROP_TRIGGERS] (
155 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
156 [TRIGGER_NAME] [NVARCHAR] (
150)
NOT NULL ,
157 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL ,
158 [STR_PROP_1] [NVARCHAR] (
512)
NULL,
159 [STR_PROP_2] [NVARCHAR] (
512)
NULL,
160 [STR_PROP_3] [NVARCHAR] (
512)
NULL,
161 [INT_PROP_1] [INT] NULL,
162 [INT_PROP_2] [INT] NULL,
163 [LONG_PROP_1] [BIGINT] NULL,
164 [LONG_PROP_2] [BIGINT] NULL,
165 [DEC_PROP_1] [NUMERIC] (
13,
4)
NULL,
166 [DEC_PROP_2] [NUMERIC] (
13,
4)
NULL,
167 [BOOL_PROP_1] BIT NULL,
168 [BOOL_PROP_2] BIT NULL,
169 )
170 GO
171
172 CREATE TABLE [dbo].
[QRTZ_BLOB_TRIGGERS] (
173 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
174 [TRIGGER_NAME] [NVARCHAR] (
150)
NOT NULL ,
175 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL ,
176 [BLOB_DATA] [IMAGE] NULL
177 )
178 GO
179
180 CREATE TABLE [dbo].
[QRTZ_TRIGGERS] (
181 [SCHED_NAME] [NVARCHAR] (
120)
NOT NULL ,
182 [TRIGGER_NAME] [NVARCHAR] (
150)
NOT NULL ,
183 [TRIGGER_GROUP] [NVARCHAR] (
150)
NOT NULL ,
184 [JOB_NAME] [NVARCHAR] (
150)
NOT NULL ,
185 [JOB_GROUP] [NVARCHAR] (
150)
NOT NULL ,
186 [DESCRIPTION] [NVARCHAR] (
250)
NULL ,
187 [NEXT_FIRE_TIME] [BIGINT] NULL ,
188 [PREV_FIRE_TIME] [BIGINT] NULL ,
189 [PRIORITY] [INTEGER] NULL ,
190 [TRIGGER_STATE] [NVARCHAR] (
16)
NOT NULL ,
191 [TRIGGER_TYPE] [NVARCHAR] (
8)
NOT NULL ,
192 [START_TIME] [BIGINT] NOT NULL ,
193 [END_TIME] [BIGINT] NULL ,
194 [CALENDAR_NAME] [NVARCHAR] (
200