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;
相关推荐
i220818 Faiz Ul5 小时前
计算机毕业设计|基于springboot + vue鲜花商城系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
Apple_羊先森7 小时前
ORACLE数据库巡检SQL脚本--22、检查碎片程度最高的业务表
数据库·sql·oracle
OnYoung8 小时前
更优雅的测试:Pytest框架入门
jvm·数据库·python
山岚的运维笔记8 小时前
SQL Server笔记 -- 第85章:查询提示
数据库·笔记·sql·microsoft·sqlserver
chilavert3189 小时前
技术演进中的开发沉思-371:final 关键字(中)
java·前端·数据库
tryCbest9 小时前
SQL Server数据库
数据库·sql server
_codemonster10 小时前
PreparedStatement 和 Statement的区别
数据库·oracle
恒云客10 小时前
python uv debug launch.json
数据库·python·json