mysql添加id-uuid 触发器

/*
Navicat MySQL Data Transfer

Source Server         : 爬虫
Source Server Version : 50173
Source Host           : 101.201.78.86:3306
Source Database       : tw_census

Target Server Type    : MYSQL
Target Server Version : 50173
File Encoding         : 65001

Date: 2017-12-22 15:58:57
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for app_channel
-- ----------------------------
DROP TABLE IF EXISTS `app_channel`;
CREATE TABLE `app_channel` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `app_id` varchar(32) NOT NULL,
  `channel_id` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  `create_user` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for app_info
-- ----------------------------
DROP TABLE IF EXISTS `app_info`;
CREATE TABLE `app_info` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `app_name` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  `create_user` varchar(32) NOT NULL,
  `app_code` varchar(32) NOT NULL,
  `app_del` int(6) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for app_pay
-- ----------------------------
DROP TABLE IF EXISTS `app_pay`;
CREATE TABLE `app_pay` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `user_id` varchar(32) NOT NULL,
  `app_id` varchar(32) NOT NULL,
  `channel_id` varchar(32) NOT NULL,
  `server_id` varchar(32) NOT NULL,
  `commodit` text,
  `price` int(11) NOT NULL,
  `pay_type` int(11) NOT NULL,
  `pay_cp_id` varchar(64) NOT NULL,
  `order_status` int(11) DEFAULT NULL COMMENT '支付状态 0:未付款,1:已付款未领取 2:已付款已领取道具',
  `pay_time` datetime NOT NULL,
  `user_k` int(32) NOT NULL,
  `aorl` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for app_server
-- ----------------------------
DROP TABLE IF EXISTS `app_server`;
CREATE TABLE `app_server` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `app_id` varchar(32) NOT NULL,
  `server_id` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  `create_user` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for app_user
-- ----------------------------
DROP TABLE IF EXISTS `app_user`;
CREATE TABLE `app_user` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `u_name` varchar(32) NOT NULL,
  `cp_id` varchar(32) NOT NULL,
  `server_id` varchar(32) NOT NULL,
  `channel_id` varchar(32) DEFAULT NULL,
  `app_id` varchar(32) DEFAULT NULL,
  `level` int(11) DEFAULT NULL,
  `game_coin` int(32) DEFAULT NULL,
  `diamond_coin` int(32) DEFAULT NULL,
  `create_ip` varchar(32) DEFAULT NULL,
  `create_time` datetime NOT NULL,
  `user_k` int(11) NOT NULL,
  `aorl` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`),
  KEY `Channel_id` (`channel_id`),
  KEY `Appid` (`app_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for channel_info
-- ----------------------------
DROP TABLE IF EXISTS `channel_info`;
CREATE TABLE `channel_info` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `channel_name` varchar(32) NOT NULL,
  `channel_code` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  `create_user` varchar(32) DEFAULT NULL,
  `partner` varchar(32) DEFAULT NULL,
  `aorl` int(6) NOT NULL,
  `channel_del` int(6) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for channel_server
-- ----------------------------
DROP TABLE IF EXISTS `channel_server`;
CREATE TABLE `channel_server` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `channel_id` varchar(32) NOT NULL,
  `server_id` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  `create_user` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for login_90_only_history
-- ----------------------------
DROP TABLE IF EXISTS `login_90_only_history`;
CREATE TABLE `login_90_only_history` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `use_id` varchar(32) NOT NULL,
  `app_id` varchar(32) NOT NULL,
  `channel_id` varchar(32) NOT NULL,
  `Server_id` varchar(32) NOT NULL,
  `login_time` datetime NOT NULL,
  `user_k` int(32) DEFAULT NULL,
  `aorl` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for login_history
-- ----------------------------
DROP TABLE IF EXISTS `login_history`;
CREATE TABLE `login_history` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `use_id` varchar(32) NOT NULL,
  `login_time` datetime NOT NULL,
  `app_id` varchar(32) NOT NULL,
  `channel_id` varchar(32) NOT NULL,
  `server_id` varchar(32) NOT NULL,
  `user_k` int(32) DEFAULT NULL,
  `aorl` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for server_info
-- ----------------------------
DROP TABLE IF EXISTS `server_info`;
CREATE TABLE `server_info` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `server_name` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  `create_user` varchar(32) DEFAULT NULL,
  `aorl` int(6) NOT NULL,
  `partner` varchar(32) DEFAULT NULL,
  `server_del` int(6) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for sys_account
-- ----------------------------
DROP TABLE IF EXISTS `sys_account`;
CREATE TABLE `sys_account` (
  `id` varchar(32) NOT NULL DEFAULT '1',
  `sys_admin` varchar(32) DEFAULT NULL,
  `ps` varchar(32) DEFAULT NULL,
  `key_sen` varchar(32) DEFAULT NULL,
  `lev` int(32) DEFAULT NULL,
  `type` int(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for test
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for test11
-- ----------------------------
DROP TABLE IF EXISTS `test11`;
CREATE TABLE `test11` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `zd1` varchar(255) DEFAULT NULL,
  `zd` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TRIGGER IF EXISTS `tri_auto_uuid_app_channel`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_app_channel` BEFORE INSERT ON `app_channel` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_app_info`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_app_info` BEFORE INSERT ON `app_info` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_app_pay`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_app_pay` BEFORE INSERT ON `app_pay` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_app_server`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_app_server` BEFORE INSERT ON `app_server` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_app_user`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_app_user` BEFORE INSERT ON `app_user` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_channel_info`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_channel_info` BEFORE INSERT ON `channel_info` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_channel_server`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_channel_server` BEFORE INSERT ON `channel_server` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_login_90_only_history`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_login_90_only_history` BEFORE INSERT ON `login_90_only_history` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_login_history`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_login_history` BEFORE INSERT ON `login_history` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_server_info`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_server_info` BEFORE INSERT ON `server_info` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tri_auto_uuid_sys_account`;
DELIMITER ;;
CREATE TRIGGER `tri_auto_uuid_sys_account` BEFORE INSERT ON `sys_account` FOR EACH ROW BEGIN
 if new.id = '1' THEN set new.id = (select REPLACE(uuid(), '-', ''));
 end if;
END
;;
DELIMITER ;

 

转载于:https://www.cnblogs.com/lazyball/p/8086643.html

你可能感兴趣的:(数据库,爬虫)