您现在的位置是: 首页 > 杂七杂八 【代码片段】MySQL新建表添加基础字段
【代码片段】MySQL新建表添加基础字段
2020-09-04 【杂七杂八】 1545人已围观 2851次浏览
简介【代码片段】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
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- Debian apt 使用国内镜像
- 类 BASE64Decoder 程序包 sun.misc 找不到符号
- SpringBoot @NotBlank 不生效问题
- 记一次 Mybatis-Plus 自动填充无效问题解决
- nuxt 项目完整部署方案
- SpringBoot 2.x 文件上传出现 The field file exceeds its maximum permitted size of 1048576 bytes
站长推荐
猜你喜欢
- 【代码片段】MySQL 查看数据库所有表注释
- RocketMQ 出现 sendDefaultImpl call timeout 问题
- nginx 出现 the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in 错误解决方案
- SqlServer 优化技巧
- 在更新python时出现dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib,Reason: image not found错误解决方案
- CentOS 安装JDK
- 解决443端口被VMWare Workstation占用
- Windows CMD 常用命令
- SpringBoot 定时任务 多线程
- Oracle ORA-12541:TNS:no listener错误解决方法