您现在的位置是: 首页 > 杂七杂八 【代码片段】MySQL新建表添加基础字段
【代码片段】MySQL新建表添加基础字段
2020-09-04 【杂七杂八】 3960人已围观 6699次浏览
简介【代码片段】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 项目完整部署方案
站长推荐
猜你喜欢
- 在更新python时出现dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib,Reason: image not found错误解决方案
- 自建Ngrok服务端
- Win10 安装适用于Linux的Windows子系统
- 解决443端口被VMWare Workstation占用
- Linux 安装 Tengine
- SpringBoot 2.x Security security.basic.enabled=false 失效问题解决
- nuxt 项目完整部署方案
- Chrome 谷歌浏览器清除HTTPS证书缓存
- SpringBoot 集成 Elasticsearch 7.8.1 出现错误 Factory method 'elasticsearchRestHighLevelClient' threw exception; nested exception is java.lang.NoSuchFieldError: IGNORE_DEPRECATIONS
- Linux 服务器之间传输大文件(压缩文件、查看MD5、后台传输)