您现在的位置是: 首页 > 杂七杂八 【代码片段】MySQL新建表添加基础字段
【代码片段】MySQL新建表添加基础字段
2020-09-04 【杂七杂八】 2933人已围观 5072次浏览
简介【代码片段】MySQL新建表添加基础字段
MySQL数据库表中,经常会用到的三个字段
SQL建表时,直接插入
gmt_create datetime null comment '创建时间',
gmt_modified datetime null comment '修改时间',
is_deleted tinyint(1) unsigned default 0 not null comment '逻辑删除标记'
或者在已有的表最后插入
alter table table_name
add gmt_create datetime null comment '创建时间';
alter table table_name
add gmt_modified datetime null comment '修改时间';
alter table table_name
add is_deleted tinyint(1) default 0 not null comment '逻辑删除标记';
对应 Java 代码,基于 MyBatis-Plus 时间字段自动填充、软删除
/**
* 创建时间
*/
@TableField(value = "gmt_create", fill = FieldFill.INSERT)
private String gmtCreate;
/**
* 修改时间
*/
@TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
private String gmtModified;
/**
* 逻辑删除标记
*/
@TableLogic
private Integer isDeleted;
很赞哦! (0)
点击排行
- Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR DISABLE You can't write or read against a disable instance
- Debian apt 使用国内镜像
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- SpringBoot @NotBlank 不生效问题
- 记一次 Mybatis-Plus 自动填充无效问题解决
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
- nuxt 项目完整部署方案
站长推荐
猜你喜欢
- 使用 OpenSSL 将 pfx 格式证书转为 pem 格式
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- nginx 出现 the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in 错误解决方案
- Linux 常用命令 持续更新中...
- SpringBoot 启动提示 Requested bean is currently in creation: Is there an unresolvable circular reference?
- ThinkPHP 解决跨域访问问题
- Vue 监听回车 el-input 和 input 使用方法不同
- cmder vim方向键无法使用 解决方案
- 在更新python时出现dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib,Reason: image not found错误解决方案
- 常见端口号