当前位置:首页 - MySql

mysql常用命令汇总

作者:高景洋 日期:2021-04-26 10:34:50 浏览次数:1333

# 在指定列后添加字段,并指定默认值

ALTER TABLE product2 ADD COLUMN LogicID VARCHAR(100) DEFAULT NULL COMMENT '逻辑ID' AFTER ID;


# 为已存在字段添加索引

ALTER TABLE product2 ADD INDEX IDX_LogicID ( `LogicID` );


# 将字符串 与 数字 拼接后,更新

update product2

set LogicID = concat('B',ID)


按周统计: select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks;
按天统计: select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days;
按月统计: select DATE_FORMAT(create_time,'%Y%m') months,count(caseid) count from tc_case group by months;

本文永久性链接:
<a href="http://r4.com.cn/art180.aspx">mysql常用命令汇总</a>
当前header:Host: r4.com.cn X-Host1: r4.com.cn X-Host2: r4.com.cn X-Host3: 127.0.0.1:8080 X-Forwarded-For: 3.129.22.34 X-Real-Ip: 3.129.22.34 X-Domain: r4.com.cn X-Request: GET /art180.aspx HTTP/1.1 X-Request-Uri: /art180.aspx Connection: close Accept: */* User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) Accept-Encoding: gzip, br, zstd, deflate