二百六十七、MySQL——海豚调度器创建MySQL库表
一、目的
为了方便部署,直接用海豚创建MySQL库表
二、实施步骤
2.1 准备好SQL文件,并上传海豚中
create database if not exists hurys_dc;
use hurys_dc;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
CREATE TABLE `tb_holiday` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '自增id',
`day` date DEFAULT NULL COMMENT '日期',
`holiday` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '节假日',
`year` varchar(50) DEFAULT NULL COMMENT '年份',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='节假日表';
##2、每天每频率的时分秒表
CREATE TABLE IF NOT EXISTS `tb_frequency_time` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键id',
`frequency_time` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '每天每频率的时分秒',
`frequency_rate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '频率',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=86696 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='每天每频率的时分秒表';
##3、周天类型表
CREATE TABLE IF NOT EXISTS `tb_week_day` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键id',
`week_day` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '周几',
`week_time` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '工作日或周末',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='周天类型表';
SET FOREIGN_KEY_CHECKS = 1;
2.2 创建海豚任务
#!/bin/bash
mysql -uroot -phurys@123<<EOF
create database if not exists hurys_dc;
use hurys_dc;
SET NAMES utf8mb4;
EOF
mysql -u用户名 -p密码 hurys_dc < 1_mysql.sql
2.3 启动海豚任务,并验证
搞定!!!