SET FOREIGN_KEY_CHECKS=0;

ALTER TABLE `exchange_option_vol` ADD COLUMN `UseFlag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '使用标识，0：使用固定值，1：使用曲面波动率' AFTER `Volatility`;

CREATE TABLE `sys_tag`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键Id',
  `TagType` int NOT NULL COMMENT '标签类型:0 交易,其它：后续待定',
  `Name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签名称',
  `Remark` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `OptId` int NULL DEFAULT NULL COMMENT '操作人',
  `OptName` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人名称',
  `OptDate` datetime NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `querybytype`(`TagType` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统标签表' ROW_FORMAT = Dynamic;

CREATE TABLE `trade_tag`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键Id',
  `TradeId` int NOT NULL COMMENT '交易Id',
  `TagId` int NOT NULL COMMENT '标签Id',
  `OptId` int NULL DEFAULT NULL COMMENT '操作人',
  `OptName` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人名称',
  `OptDate` datetime NULL DEFAULT NULL COMMENT '操作时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `querybytradeid`(`TradeId` ASC) USING BTREE,
  INDEX `querybytagid`(`TagId` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '交易 标签 关联表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS=1;
