通过下面的类给我生成建表语句 @TableName("comment") public class Comment { @TableId(value = "id", type = IdType.AUTO) private Integer id; private Integer uid; private String uname; private String avatar; private Date time; private String content; //回复的帖子id private Integer pid; private Integer status; private Date createTime; private Date updateTime; //删除标志(0代表未删除,1代表已删除) private Integer delFlag; @TableField(exist = false) private List<Answer> answerList;//记录这条评论的所有回复 }
时间: 2023-05-21 16:05:54 浏览: 112
生成建表语句如下:
CREATE TABLE `comment` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL,
`uname` varchar(255) DEFAULT NULL,
`avatar` varchar(255) DEFAULT NULL,
`time` datetime DEFAULT NULL,
`content` varchar(255) DEFAULT NULL,
`pid` int(11) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`createTime` datetime DEFAULT NULL,
`updateTime` datetime DEFAULT NULL,
`delFlag` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
相关问题
根据下面类生成数据库建表语句 @TableName("type") public class Type { @TableId(value = "id", type = IdType.AUTO) private Integer id; private String name; private String description; @TableField(exist = false) private Integer type_num; } @TableName("user") public class User {
CREATE TABLE type (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
description VARCHAR(255) NOT NULL,
type_num INT
);
CREATE TABLE user (
-- assuming default ID is AUTO_INCREMENT and PRIMARY KEY
id INT PRIMARY KEY AUTO_INCREMENT,
-- assuming name is varchar with max length 255
name VARCHAR(255) NOT NULL,
-- assuming email is unique for each user
email VARCHAR(255) UNIQUE NOT NULL
);
通过下面类给我生成建表语句 @TableName("mention") public class Mention { @TableId(value = "id", type = IdType.AUTO) private Integer id; private Integer fromId; private Integer toId; private String title; private String description; private String content; private Date time; private Integer status; private Integer typeId; private Integer pid; private Date createTime; private Date updateTime; //删除标志(0代表未删除,1代表已删除) private Integer delFlag; } @TableName("message") public class Message { @TableId(value = "id", type = IdType.AUTO) private Integer id; private Integer toId; private String message; private Date time; private Integer typeId; //代表是否被读 private Integer status; private Date createTime; private Date updateTime; //删除标志(0代表未删除,1代表已删除) private Integer delFlag; }
下面是Mention和Message类对应的建表语句:
CREATE TABLE mention (
id INT AUTO_INCREMENT PRIMARY KEY,
fromId INT NOT NULL,
toId INT NOT NULL,
title VARCHAR(255),
description VARCHAR(255),
content TEXT,
time DATETIME,
status INT NOT NULL,
typeId INT NOT NULL,
pid INT,
createTime DATETIME,
updateTime DATETIME,
delFlag INT NOT NULL
);
CREATE TABLE message (
id INT AUTO_INCREMENT PRIMARY KEY,
toId INT NOT NULL,
message TEXT,
time DATETIME,
typeId INT NOT NULL,
status INT NOT NULL,
createTime DATETIME,
updateTime DATETIME,
delFlag INT NOT NULL
);
阅读全文