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;