quartz.sql 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. delete from qrtz_fired_triggers;
  2. delete from qrtz_simple_triggers;
  3. delete from qrtz_simprop_triggers;
  4. delete from qrtz_cron_triggers;
  5. delete from qrtz_blob_triggers;
  6. delete from qrtz_triggers;
  7. delete from qrtz_job_details;
  8. delete from qrtz_calendars;
  9. delete from qrtz_paused_trigger_grps;
  10. delete from qrtz_locks;
  11. delete from qrtz_scheduler_state;
  12. drop table qrtz_calendars;
  13. drop table qrtz_fired_triggers;
  14. drop table qrtz_blob_triggers;
  15. drop table qrtz_cron_triggers;
  16. drop table qrtz_simple_triggers;
  17. drop table qrtz_simprop_triggers;
  18. drop table qrtz_triggers;
  19. drop table qrtz_job_details;
  20. drop table qrtz_paused_trigger_grps;
  21. drop table qrtz_locks;
  22. drop table qrtz_scheduler_state;
  23. -- ----------------------------
  24. -- 1、存储每一个已配置的 jobDetail 的详细信息
  25. -- ----------------------------
  26. create table qrtz_job_details (
  27. sched_name varchar2(120) not null,
  28. job_name varchar2(200) not null,
  29. job_group varchar2(200) not null,
  30. description varchar2(250) null,
  31. job_class_name varchar2(250) not null,
  32. is_durable varchar2(1) not null,
  33. is_nonconcurrent varchar2(1) not null,
  34. is_update_data varchar2(1) not null,
  35. requests_recovery varchar2(1) not null,
  36. job_data blob null,
  37. constraint qrtz_job_details_pk primary key (sched_name, job_name, job_group)
  38. );
  39. comment on table qrtz_job_details is '任务详细信息表';
  40. comment on column qrtz_job_details.sched_name is '调度名称';
  41. comment on column qrtz_job_details.job_name is '任务名称';
  42. comment on column qrtz_job_details.job_group is '任务组名';
  43. comment on column qrtz_job_details.description is '相关介绍';
  44. comment on column qrtz_job_details.job_class_name is '执行任务类名称';
  45. comment on column qrtz_job_details.is_durable is '是否持久化';
  46. comment on column qrtz_job_details.is_nonconcurrent is '是否并发';
  47. comment on column qrtz_job_details.is_update_data is '是否更新数据';
  48. comment on column qrtz_job_details.requests_recovery is '是否接受恢复执行';
  49. comment on column qrtz_job_details.job_data is '存放持久化job对象';
  50. -- ----------------------------
  51. -- 2、 存储已配置的 Trigger 的信息
  52. -- ----------------------------
  53. create table qrtz_triggers (
  54. sched_name varchar2(120) not null,
  55. trigger_name varchar2(200) not null,
  56. trigger_group varchar2(200) not null,
  57. job_name varchar2(200) not null,
  58. job_group varchar2(200) not null,
  59. description varchar2(250) null,
  60. next_fire_time number(13) null,
  61. prev_fire_time number(13) null,
  62. priority number(13) null,
  63. trigger_state varchar2(16) not null,
  64. trigger_type varchar2(8) not null,
  65. start_time number(13) not null,
  66. end_time number(13) null,
  67. calendar_name varchar2(200) null,
  68. misfire_instr number(2) null,
  69. job_data blob null,
  70. constraint qrtz_triggers_pk primary key (sched_name, trigger_name, trigger_group),
  71. constraint qrtz_trigger_to_jobs_fk foreign key (sched_name, job_name, job_group) references qrtz_job_details(sched_name, job_name, job_group)
  72. );
  73. comment on table qrtz_triggers is '触发器详细信息表';
  74. comment on column qrtz_triggers.sched_name is '调度名称';
  75. comment on column qrtz_triggers.trigger_name is '触发器的名字';
  76. comment on column qrtz_triggers.trigger_group is '触发器所属组的名字';
  77. comment on column qrtz_triggers.job_name is 'qrtz_job_details表job_name的外键';
  78. comment on column qrtz_triggers.job_group is 'qrtz_job_details表job_group的外键';
  79. comment on column qrtz_triggers.description is '相关介绍';
  80. comment on column qrtz_triggers.next_fire_time is '上一次触发时间(毫秒)';
  81. comment on column qrtz_triggers.prev_fire_time is '下一次触发时间(默认为-1表示不触发)';
  82. comment on column qrtz_triggers.priority is '优先级';
  83. comment on column qrtz_triggers.trigger_state is '触发器状态';
  84. comment on column qrtz_triggers.trigger_type is '触发器的类型';
  85. comment on column qrtz_triggers.start_time is '开始时间';
  86. comment on column qrtz_triggers.end_time is '结束时间';
  87. comment on column qrtz_triggers.calendar_name is '日程表名称';
  88. comment on column qrtz_triggers.misfire_instr is '补偿执行的策略';
  89. comment on column qrtz_triggers.job_data is '存放持久化job对象';
  90. -- ----------------------------
  91. -- 3、 存储简单的 Trigger,包括重复次数,间隔,以及已触发的次数
  92. -- ----------------------------
  93. create table qrtz_simple_triggers (
  94. sched_name varchar2(120) not null,
  95. trigger_name varchar2(200) not null,
  96. trigger_group varchar2(200) not null,
  97. repeat_count number(7) not null,
  98. repeat_interval number(12) not null,
  99. times_triggered number(10) not null,
  100. constraint qrtz_simple_trig_pk primary key (sched_name, trigger_name, trigger_group),
  101. constraint qrtz_simple_trig_to_trig_fk foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers(sched_name, trigger_name, trigger_group)
  102. );
  103. comment on table qrtz_simple_triggers is '简单触发器的信息表';
  104. comment on column qrtz_simple_triggers.sched_name is '调度名称';
  105. comment on column qrtz_simple_triggers.trigger_name is 'qrtz_triggers表trigger_name的外键';
  106. comment on column qrtz_simple_triggers.trigger_group is 'qrtz_triggers表trigger_group的外键';
  107. comment on column qrtz_simple_triggers.repeat_count is '重复的次数统计';
  108. comment on column qrtz_simple_triggers.repeat_interval is '重复的间隔时间';
  109. comment on column qrtz_simple_triggers.times_triggered is '已经触发的次数';
  110. -- ----------------------------
  111. -- 4、 存储 Cron Trigger,包括 Cron 表达式和时区信息
  112. -- ----------------------------
  113. create table qrtz_cron_triggers (
  114. sched_name varchar2(120) not null,
  115. trigger_name varchar2(200) not null,
  116. trigger_group varchar2(200) not null,
  117. cron_expression varchar2(120) not null,
  118. time_zone_id varchar2(80),
  119. constraint qrtz_cron_trig_pk primary key (sched_name, trigger_name, trigger_group),
  120. constraint qrtz_cron_trig_to_trig_fk foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers(sched_name, trigger_name, trigger_group)
  121. );
  122. comment on table qrtz_cron_triggers is 'Cron类型的触发器表';
  123. comment on column qrtz_cron_triggers.sched_name is '调度名称';
  124. comment on column qrtz_cron_triggers.trigger_name is 'qrtz_triggers表trigger_name的外键';
  125. comment on column qrtz_cron_triggers.trigger_group is 'qrtz_triggers表trigger_group的外键';
  126. comment on column qrtz_cron_triggers.cron_expression is 'cron表达式';
  127. comment on column qrtz_cron_triggers.time_zone_id is '时区';
  128. -- ----------------------------
  129. -- 5、 Trigger 作为 Blob 类型存储(用于 Quartz 用户用 JDBC 创建他们自己定制的 Trigger 类型,JobStore 并不知道如何存储实例的时候)
  130. -- ----------------------------
  131. create table qrtz_blob_triggers (
  132. sched_name varchar2(120) not null,
  133. trigger_name varchar2(200) not null,
  134. trigger_group varchar2(200) not null,
  135. blob_data blob null,
  136. constraint qrtz_blob_trig_pk primary key (sched_name, trigger_name, trigger_group),
  137. constraint qrtz_blob_trig_to_trig_fk foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers(sched_name, trigger_name, trigger_group)
  138. );
  139. comment on table qrtz_blob_triggers is 'Blob类型的触发器表';
  140. comment on column qrtz_blob_triggers.sched_name is '调度名称';
  141. comment on column qrtz_blob_triggers.trigger_name is 'qrtz_triggers表trigger_name的外键';
  142. comment on column qrtz_blob_triggers.trigger_group is 'qrtz_triggers表trigger_group的外键';
  143. comment on column qrtz_blob_triggers.blob_data is '存放持久化Trigger对象';
  144. -- ----------------------------
  145. -- 6、 以 Blob 类型存储存放日历信息, quartz可配置一个日历来指定一个时间范围
  146. -- ----------------------------
  147. create table qrtz_calendars (
  148. sched_name varchar2(120) not null,
  149. calendar_name varchar2(200) not null,
  150. calendar blob not null,
  151. constraint qrtz_calendars_pk primary key (sched_name, calendar_name)
  152. );
  153. comment on table qrtz_calendars is '日历信息表';
  154. comment on column qrtz_calendars.sched_name is '调度名称';
  155. comment on column qrtz_calendars.calendar_name is '日历名称';
  156. comment on column qrtz_calendars.calendar is '存放持久化calendar对象';
  157. -- ----------------------------
  158. -- 7、 存储已暂停的 Trigger 组的信息
  159. -- ----------------------------
  160. create table qrtz_paused_trigger_grps (
  161. sched_name varchar2(120) not null,
  162. trigger_group varchar2(200) not null,
  163. constraint qrtz_paused_trig_grps_pk primary key (sched_name, trigger_group)
  164. );
  165. comment on table qrtz_paused_trigger_grps is '暂停的触发器表';
  166. comment on column qrtz_paused_trigger_grps.sched_name is '调度名称';
  167. comment on column qrtz_paused_trigger_grps.trigger_group is 'qrtz_triggers表trigger_group的外键';
  168. -- ----------------------------
  169. -- 8、 存储与已触发的 Trigger 相关的状态信息,以及相联 Job 的执行信息
  170. -- ----------------------------
  171. create table qrtz_fired_triggers (
  172. sched_name varchar2(120) not null,
  173. entry_id varchar2(95) not null,
  174. trigger_name varchar2(200) not null,
  175. trigger_group varchar2(200) not null,
  176. instance_name varchar2(200) not null,
  177. fired_time number(13) not null,
  178. sched_time number(13) not null,
  179. priority number(13) not null,
  180. state varchar2(16) not null,
  181. job_name varchar2(200) null,
  182. job_group varchar2(200) null,
  183. is_nonconcurrent varchar2(1) null,
  184. requests_recovery varchar2(1) null,
  185. constraint qrtz_fired_trigger_pk primary key (sched_name, entry_id)
  186. );
  187. comment on table qrtz_fired_triggers is '已触发的触发器表';
  188. comment on column qrtz_fired_triggers.sched_name is '调度名称';
  189. comment on column qrtz_fired_triggers.entry_id is '调度器实例id';
  190. comment on column qrtz_fired_triggers.trigger_name is 'qrtz_triggers表trigger_name的外键';
  191. comment on column qrtz_fired_triggers.trigger_group is 'qrtz_triggers表trigger_group的外键';
  192. comment on column qrtz_fired_triggers.instance_name is '调度器实例名';
  193. comment on column qrtz_fired_triggers.fired_time is '触发的时间';
  194. comment on column qrtz_fired_triggers.sched_time is '定时器制定的时间';
  195. comment on column qrtz_fired_triggers.priority is '优先级';
  196. comment on column qrtz_fired_triggers.state is '状态';
  197. comment on column qrtz_fired_triggers.job_name is '任务名称';
  198. comment on column qrtz_fired_triggers.job_group is '任务组名';
  199. comment on column qrtz_fired_triggers.is_nonconcurrent is '是否并发';
  200. comment on column qrtz_fired_triggers.requests_recovery is '是否接受恢复执行';
  201. -- ----------------------------
  202. -- 9、 存储少量的有关 Scheduler 的状态信息,假如是用于集群中,可以看到其他的 Scheduler 实例
  203. -- ----------------------------
  204. create table qrtz_scheduler_state (
  205. sched_name varchar2(120) not null,
  206. instance_name varchar2(200) not null,
  207. last_checkin_time number(13) not null,
  208. checkin_interval number(13) not null,
  209. constraint qrtz_scheduler_state_pk primary key (sched_name, instance_name)
  210. );
  211. comment on table qrtz_scheduler_state is '调度器状态表';
  212. comment on column qrtz_scheduler_state.sched_name is '调度名称';
  213. comment on column qrtz_scheduler_state.instance_name is '实例名称';
  214. comment on column qrtz_scheduler_state.last_checkin_time is '上次检查时间';
  215. comment on column qrtz_scheduler_state.checkin_interval is '检查间隔时间';
  216. -- ----------------------------
  217. -- 10、 存储程序的悲观锁的信息(假如使用了悲观锁)
  218. -- ----------------------------
  219. create table qrtz_locks (
  220. sched_name varchar2(120) not null,
  221. lock_name varchar2(40) not null,
  222. constraint qrtz_locks_pk primary key (sched_name, lock_name)
  223. );
  224. comment on table qrtz_locks is '存储的悲观锁信息表';
  225. comment on column qrtz_locks.sched_name is '调度名称';
  226. comment on column qrtz_locks.lock_name is '悲观锁名称';
  227. -- ----------------------------
  228. -- 11、 Quartz集群实现同步机制的行锁表
  229. -- ----------------------------
  230. create table qrtz_simprop_triggers (
  231. sched_name varchar2(120) not null,
  232. trigger_name varchar2(200) not null,
  233. trigger_group varchar2(200) not null,
  234. str_prop_1 varchar2(512) null,
  235. str_prop_2 varchar2(512) null,
  236. str_prop_3 varchar2(512) null,
  237. int_prop_1 number(10) null,
  238. int_prop_2 number(10) null,
  239. long_prop_1 number(13) null,
  240. long_prop_2 number(13) null,
  241. dec_prop_1 numeric(13,4) null,
  242. dec_prop_2 numeric(13,4) null,
  243. bool_prop_1 varchar2(1) null,
  244. bool_prop_2 varchar2(1) null,
  245. constraint qrtz_simprop_trig_pk primary key (sched_name, trigger_name, trigger_group),
  246. constraint qrtz_simprop_trig_to_trig_fk foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers(sched_name, trigger_name, trigger_group)
  247. );
  248. comment on table qrtz_simprop_triggers is '同步机制的行锁表';
  249. comment on column qrtz_simprop_triggers.sched_name is '调度名称';
  250. comment on column qrtz_simprop_triggers.trigger_name is 'qrtz_triggers表trigger_name的外键';
  251. comment on column qrtz_simprop_triggers.trigger_group is 'qrtz_triggers表trigger_group的外键';
  252. comment on column qrtz_simprop_triggers.str_prop_1 is 'String类型的trigger的第一个参数';
  253. comment on column qrtz_simprop_triggers.str_prop_2 is 'String类型的trigger的第二个参数';
  254. comment on column qrtz_simprop_triggers.str_prop_3 is 'String类型的trigger的第三个参数';
  255. comment on column qrtz_simprop_triggers.int_prop_1 is 'int类型的trigger的第一个参数';
  256. comment on column qrtz_simprop_triggers.int_prop_2 is 'int类型的trigger的第二个参数';
  257. comment on column qrtz_simprop_triggers.long_prop_1 is 'long类型的trigger的第一个参数';
  258. comment on column qrtz_simprop_triggers.long_prop_2 is 'long类型的trigger的第二个参数';
  259. comment on column qrtz_simprop_triggers.dec_prop_1 is 'decimal类型的trigger的第一个参数';
  260. comment on column qrtz_simprop_triggers.dec_prop_2 is 'decimal类型的trigger的第二个参数';
  261. comment on column qrtz_simprop_triggers.bool_prop_1 is 'Boolean类型的trigger的第一个参数';
  262. comment on column qrtz_simprop_triggers.bool_prop_2 is 'Boolean类型的trigger的第二个参数';
  263. create index idx_qrtz_j_req_recovery on qrtz_job_details(sched_name, requests_recovery);
  264. create index idx_qrtz_j_grp on qrtz_job_details(sched_name, job_group);
  265. create index idx_qrtz_t_j on qrtz_triggers(sched_name, job_name, job_group);
  266. create index idx_qrtz_t_jg on qrtz_triggers(sched_name, job_group);
  267. create index idx_qrtz_t_c on qrtz_triggers(sched_name, calendar_name);
  268. create index idx_qrtz_t_g on qrtz_triggers(sched_name, trigger_group);
  269. create index idx_qrtz_t_state on qrtz_triggers(sched_name, trigger_state);
  270. create index idx_qrtz_t_n_state on qrtz_triggers(sched_name, trigger_name, trigger_group, trigger_state);
  271. create index idx_qrtz_t_n_g_state on qrtz_triggers(sched_name, trigger_group, trigger_state);
  272. create index idx_qrtz_t_next_fire_time on qrtz_triggers(sched_name, next_fire_time);
  273. create index idx_qrtz_t_nft_st on qrtz_triggers(sched_name, trigger_state, next_fire_time);
  274. create index idx_qrtz_t_nft_misfire on qrtz_triggers(sched_name, misfire_instr, next_fire_time);
  275. create index idx_qrtz_t_nft_st_misfire on qrtz_triggers(sched_name, misfire_instr, next_fire_time, trigger_state);
  276. create index idx_qrtz_t_nft_st_misfire_grp on qrtz_triggers(sched_name, misfire_instr, next_fire_time, trigger_group, trigger_state);
  277. create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(sched_name, instance_name);
  278. create index idx_qrtz_ft_inst_job_req_rcvry on qrtz_fired_triggers(sched_name, instance_name, requests_recovery);
  279. create index idx_qrtz_ft_j_g on qrtz_fired_triggers(sched_name, job_name, job_group);
  280. create index idx_qrtz_ft_jg on qrtz_fired_triggers(sched_name, job_group);
  281. create index idx_qrtz_ft_t_g on qrtz_fired_triggers(sched_name, trigger_name, trigger_group);
  282. create index idx_qrtz_ft_tg on qrtz_fired_triggers(sched_name, trigger_group);
  283. commit;