0%

12.3 准备数据库资源

12.3 准备数据库资源

mybatis数据库中创建两个表tb_usertb_book,并插入测试数据,SQL脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Navicat MySQL Data Transfer

Source Server : localhost_3306
Source Server Version : 50508
Source Host : localhost:3306
Source Database : mybatis

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

Date: 2019-09-11 20:47:15
*/

SET FOREIGN_KEY_CHECKS=0;

DROP TABLE IF EXISTS `tb_book`;
CREATE TABLE `tb_book` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(54) DEFAULT NULL,
`author` varchar(54) DEFAULT NULL,
`publicationdate` date DEFAULT NULL,
`publication` varchar(150) DEFAULT NULL,
`price` double DEFAULT NULL,
`image` varchar(54) DEFAULT NULL,
`remark` varchar(600) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;

INSERT INTO `tb_book` VALUES ('1', '书名1', '作者1', '2018-10-01', '电子工业出版社', '72.1', 'images/java.jpg', '书的简介');

DROP TABLE IF EXISTS `tb_user`;
CREATE TABLE `tb_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`loginname` varchar(50) DEFAULT NULL,
`password` varchar(18) DEFAULT NULL,
`username` varchar(18) DEFAULT NULL,
`phone` varchar(18) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `loginname` (`loginname`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;

INSERT INTO `tb_user` VALUES ('1', 'xiaoming', 'xiaoming', '小明', '123456789123', '上海');

原文链接: 12.3 准备数据库资源