mysql自动填写当前时间,添加索引

mysql自动填写当前时间

在navicat操作界面创建表时,如果需要自动填写时间,可以操作如下

复制代码
CURRENT_TIMESTAMP

为表添加索引

复制代码
ALTER table tableName ADD INDEX indexName(columnName)

追加外键

复制代码
ALTER TABLE tb_commentPhoto ADD CONSTRAINT FK_comment_phone
FOREIGN KEY tb_goodsComment(id) REFERENCES tb_commentPhoto(comment_id);

mysql更新语句、新增列、删除列

复制代码
# 更新
update user set name='张三' where id=111
# 删除
DELETE FROM table_name [WHERE Clause]

# 增加字段
alter table 表名 add column 列名 类型;
# 删除字段
alter table 表名 dropcolumn 列名 ;

联合更新

复制代码
    # 联合更新
    update malluser set master_master_id=3 where master_id in (select a.id from (select id from  malluser where id like '15%')a)  

统计某字段重复数据

复制代码
    # 统计某字段重复数据
    SELECT phone, COUNT(*) AS sumCount FROM malluser GROUP BY phone HAVING sumCount > 1;
相关推荐
苍煜12 分钟前
慢SQL优化实战教学
java·数据库·sql
zhaoyong2221 小时前
MySQL 存储过程中字符集与排序规则不匹配导致查询性能下降的解决方案
jvm·数据库·python
sinat_383437361 小时前
golang如何从Python转型Go开发_golang从Python转型Go开发攻略
jvm·数据库·python
远洪1 小时前
claude code 国内安装使用
数据库·mysql
雨辰AI1 小时前
SpringBoot3 + 人大金仓 V9 微服务监控实战|Prometheus+Grafana+SkyWalking 全链路监控
数据库·后端·微服务·grafana·prometheus·skywalking
二哈赛车手1 小时前
新人笔记---ES和kibana启动问题以及一些常用的linux的错误排查方法,以及ES,数据库泄密解决方案[超详细]
java·linux·数据库·spring boot·笔记·elasticsearch
myrh pdmd1 小时前
maven导入spring框架
数据库·spring·maven
爬山算法2 小时前
MongoDB(118)如何在升级过程中进行数据备份?
数据库·mongodb·oracle
千月落2 小时前
Redis数据迁移
数据库·redis·缓存
wangbing11253 小时前
MySQL 官方 GPG 密钥过期问题
数据库·mysql