一共4张表,如图
sql语句如下:
/* SQLyog 企业版 - MySQL GUI v8.14 MySQL - 5.6.24 : Database - vip ********************************************************************* */ /*!40101 SET NAMES utf8 */; /*!40101 SET SQL_MODE=‘‘*/; /*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @[email protected]@SQL_MODE, SQL_MODE=‘NO_AUTO_VALUE_ON_ZERO‘ */; /*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */; CREATE DATABASE /*!32312 IF NOT EXISTS*/`vip` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `vip`; /*Table structure for table `tbl_sys_user` */ DROP TABLE IF EXISTS `tbl_sys_user`; CREATE TABLE `tbl_sys_user` ( `id` char(32) NOT NULL, `account` varchar(32) NOT NULL, `name` varchar(32) NOT NULL, `password` varchar(16) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `tbl_sys_user` */ insert into `tbl_sys_user`(`id`,`account`,`name`,`password`) values (‘1‘,‘admin‘,‘admin‘,‘admin‘); /*Table structure for table `tbl_vip_consume` */ DROP TABLE IF EXISTS `tbl_vip_consume`; CREATE TABLE `tbl_vip_consume` ( `id` char(32) NOT NULL, `vip_id` char(32) DEFAULT NULL, `whens` datetime DEFAULT NULL, `orderno` varchar(32) DEFAULT NULL, `amount` int(11) DEFAULT NULL COMMENT ‘消费金额,以分为单位‘, `operator_id` char(32) DEFAULT NULL, `remark` varchar(256) DEFAULT NULL, `flag` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`), KEY `FK_tbl_vip_consume` (`vip_id`), CONSTRAINT `FK_tbl_vip_consume` FOREIGN KEY (`vip_id`) REFERENCES `tbl_vip_detail` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `tbl_vip_consume` */ insert into `tbl_vip_consume`(`id`,`vip_id`,`whens`,`orderno`,`amount`,`operator_id`,`remark`,`flag`) values (‘1‘,‘1‘,‘2017-07-07 00:00:00‘,‘10001‘,50,‘10001‘,NULL,NULL); /*Table structure for table `tbl_vip_detail` */ DROP TABLE IF EXISTS `tbl_vip_detail`; CREATE TABLE `tbl_vip_detail` ( `id` char(32) NOT NULL, `code` varchar(32) DEFAULT NULL, `name` varchar(32) DEFAULT NULL, `sex` tinyint(1) DEFAULT NULL, `age` tinyint(4) DEFAULT NULL, `qq` varchar(32) DEFAULT NULL, `email` varchar(32) DEFAULT NULL, `address` varchar(128) DEFAULT NULL, `zip` varchar(16) DEFAULT NULL, `remark` varchar(256) DEFAULT NULL, `rank` tinyint(1) DEFAULT NULL, `account` int(11) DEFAULT NULL COMMENT ‘消费金额,单位分‘, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `tbl_vip_detail` */ insert into `tbl_vip_detail`(`id`,`code`,`name`,`sex`,`age`,`qq`,`email`,`address`,`zip`,`remark`,`rank`,`account`) values (‘1‘,‘10001‘,‘Tom‘,1,22,‘10002200‘,‘[email protected]‘,‘beijing‘,NULL,NULL,1,50); /*Table structure for table `tbl_vip_rank` */ DROP TABLE IF EXISTS `tbl_vip_rank`; CREATE TABLE `tbl_vip_rank` ( `no` tinyint(1) DEFAULT NULL, `name` varchar(32) DEFAULT NULL, `needAmount` int(11) DEFAULT NULL, `remark` varchar(128) DEFAULT NULL, `discount` tinyint(4) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*Data for the table `tbl_vip_rank` */ insert into `tbl_vip_rank`(`no`,`name`,`needAmount`,`remark`,`discount`) values (1,‘普通VIP‘,1,NULL,98),(2,‘黄金VIP‘,100,NULL,95),(3,‘白金VIP‘,1000,NULL,90),(4,‘钻石VIP‘,5000,NULL,88),(5,‘终生VIP‘,10000,NULL,85); /*!40101 SET [email protected]_SQL_MODE */; /*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */; /*!40014 SET [email protected]_UNIQUE_CHECKS */; /*!40111 SET [email protected]_SQL_NOTES */;
时间: 2024-10-02 23:46:45