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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `test`.`blog`; DROP TABLE IF EXISTS `test`.`category`; DROP TABLE IF EXISTS `test`.`comment`; DROP TABLE IF EXISTS `test`.`links`; DROP TABLE IF EXISTS `test`.`user`; DROP TABLE IF EXISTS `test`.`user_follow`; CREATE TABLE `blog` ( `id` int NOT NULL COMMENT '文章id', `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文章标题', `author_id` int NOT NULL COMMENT '作者id', `category_id` int NOT NULL COMMENT '分类id', `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文章内容', `create_time` datetime NOT NULL COMMENT '创建时间', `update_time` datetime NOT NULL COMMENT '更新时间', `love` int DEFAULT NULL COMMENT '点赞', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `category` ( `id` int NOT NULL COMMENT '分类id', `category_name` varchar(30) NOT NULL COMMENT '分类名称', `create_user_id` int DEFAULT NULL COMMENT '创建分类的用户id', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `comment` ( `id` int NOT NULL COMMENT '评论id', `blog_id` int NOT NULL COMMENT '博客id', `user_id` int NOT NULL COMMENT '用户id', `content` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '评论内容', `create_time` datetime NOT NULL COMMENT '创建时间', `user_id_parent` int NOT NULL COMMENT '回复人的id', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `links` ( `id` int NOT NULL COMMENT '友链id', `links` varchar(50) NOT NULL COMMENT '网站名称', `href` varchar(2000) NOT NULL COMMENT '网站链接', `sort` int NOT NULL COMMENT '排序', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `user` ( `id` int NOT NULL COMMENT '用户id', `username` varchar(60) NOT NULL COMMENT '用户名', `password` varchar(60) NOT NULL COMMENT '用户密码', `sex` varchar(2) NOT NULL COMMENT '性别', `age` int DEFAULT NULL COMMENT '年龄', `sign` varchar(255) DEFAULT NULL COMMENT '签名', `open_id` varchar(1000) NOT NULL COMMENT '微信id', `avatar` varchar(1000) NOT NULL COMMENT '头像地址', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; CREATE TABLE `user_follow` ( `id` int NOT NULL COMMENT '关注表id', `user_id` int NOT NULL COMMENT '被关注的id', `follow_id` int NOT NULL COMMENT '关注人的id', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; BEGIN; LOCK TABLES `test`.`blog` WRITE; DELETE FROM `test`.`blog`; UNLOCK TABLES; COMMIT; BEGIN; LOCK TABLES `test`.`category` WRITE; DELETE FROM `test`.`category`; UNLOCK TABLES; COMMIT; BEGIN; LOCK TABLES `test`.`comment` WRITE; DELETE FROM `test`.`comment`; UNLOCK TABLES; COMMIT; BEGIN; LOCK TABLES `test`.`links` WRITE; DELETE FROM `test`.`links`; UNLOCK TABLES; COMMIT; BEGIN; LOCK TABLES `test`.`user` WRITE; DELETE FROM `test`.`user`; UNLOCK TABLES; COMMIT; BEGIN; LOCK TABLES `test`.`user_follow` WRITE; DELETE FROM `test`.`user_follow`; UNLOCK TABLES; COMMIT;
|