针对MYSQL创建表的sql 索引约束合并问题

如果含有主键、约束、索引中,含有列是一样的问题,软件会根据主键>约束>索引的权限情况下,优先创建,多余的对象,将自动忽略,
比如

CREATE TABLE `bus_task` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `mid` int(11) NOT NULL COMMENT '维护商ID',
  `containerid` int(11) NOT NULL,
  `group_id` int(11) NOT NULL COMMENT '分组id',
  `task_name` varchar(255) DEFAULT NULL COMMENT '任务名',
  `task_init_start` int(11) DEFAULT '1' COMMENT '平台启动时,同时启动任务 1=初始化启动 0=非初始化启动',
  `dispatch_type` int(11) DEFAULT '0' COMMENT '任务调度类型(默认值=0)\r\n0=立即执行\r\n1=定时执行\r\n',
  `dispatch_circulate` int(11) DEFAULT NULL COMMENT '循环时间\r\ndispatch_type=0,此字段生效\r\n分钟为单位\r\n',
  `dispatch_cycle` int(11) DEFAULT NULL COMMENT '定时周期\r\ndispatch_type=1\r\nYear\r\nMonth\r\nWeek\r\nDay\r\n',
  `dispatch_week` int(11) DEFAULT '1' COMMENT '当选择周,存放周几\r\n1/2/3/4/5/6/7',
  `dispatch_crontab` varchar(32) DEFAULT NULL COMMENT '任务执行字符串',
  `dispatch_time` datetime DEFAULT NULL COMMENT '定时时间\r\ndispatch_type=1,此字段生效\r\n精确到秒\r\n与patch_ cycle,配合使用\r\n',
  `task_run_status` int(11) DEFAULT '0' COMMENT '0 未运行  1 运行中 2 运行完成 \r\n\r\n用于检查最后一次任务是否完成,未完成,跳过下次在执行',
  `status` int(11) DEFAULT '0' COMMENT '0 初始化 1 允许运行 2 运行中 3 停止运行 4 停止完成 ',
  `updatetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '建立、更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_bus_task_id` (`id`),
  KEY `group_id` (`group_id`),
  KEY `idx_001` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 COMMENT='任务表' ;

翻译到ORACLE 为

CREATE TABLE "PICC"."CIINSUREDEMAND" ("ID" integer NOT NULL ,"MID" integer NOT NULL ,"CONTAINERID" integer NOT NULL ,"GROUP_ID" integer NOT NULL ,"TASK_NAME" varchar2(510) ,"TASK_INIT_START" integer  DEFAULT  '1' ,"DISPATCH_TYPE" integer  DEFAULT  '0' ,"DISPATCH_CIRCULATE" integer ,"DISPATCH_CYCLE" integer ,"DISPATCH_WEEK" integer  DEFAULT  '1' ,"DISPATCH_CRONTAB" varchar2(64) ,"DISPATCH_TIME" date NULL ,"TASK_RUN_STATUS" integer  DEFAULT  '0' ,"STATUS" integer  DEFAULT  '0' ,"UPDATETIME" timestamp NOT NULL ) ;
ALTER TABLE "PICC"."CIINSUREDEMAND" ADD PRIMARY KEY ("ID") ;
CREATE INDEX PICC.group_id ON PICC.CIINSUREDEMAND ( "GROUP_ID" )  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."ID" is '主键'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."MID" is '维护商ID'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."GROUP_ID" is '分组id'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."TASK_NAME" is '任务名'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."TASK_INIT_START" is '平台启动时,同时启动任务 1=初始化启动 0=非初始化启动'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."DISPATCH_TYPE" is '任务调度类型(默认值=0) 0=立即执行 1=定时执行 '  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."DISPATCH_CIRCULATE" is '循环时间 dispatch_type=0,此字段生效 分钟为单位'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."DISPATCH_CYCLE" is '定时周期 dispatch_type=1 Year Month Week Day'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."DISPATCH_WEEK" is '当选择周,存放周几 1234567'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."DISPATCH_CRONTAB" is '任务执行字符串'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."DISPATCH_TIME" is '定时时间 dispatch_type=1,此字段生效 精确到秒 与patch_ cycle,配合使用 '  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."TASK_RUN_STATUS" is '0 未运行 1 运行中 2 运行完成 用于检查最后一次任务是否完成,未完成,跳过下次在执行'  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."STATUS" is '0 初始化 1 允许运行 2 运行中 3 停止运行 4 停止完成 '  ;
COMMENT ON COLUMN "PICC"."CIINSUREDEMAND"."UPDATETIME" is '建立、更新时间'  ;
COMMENT ON TABLE "PICC"."CIINSUREDEMAND" is '任务表'  ;
文档更新时间: 2022-09-18 17:28   作者:阿力