我的学习生活记录

这里是SUYE的站点

mysql常用语句

2021-3-12 夙夜 实际技能

show variables like '%connect%';
查询mysql配置

show full columns from tablename;/show full fields from tablename;
获取表中注释


date_format(READDATE,'%Y%m')
输出去除横杠的时间

update test as a, test as b set a.aa=b.bb ,a.bb=b.aa where a.id=b.id
互换两列值位置

语句前加EXPLAIN 显示该语句是否使用索引
两语句之间加UNION拼接查询结果

select table_schema,sum(data_length+index_length)/1024/1024/1024 GB from information_schema.tables group by table_schema;
查询所有数据库大小

CONVERT(koujing,SIGNED)
某个字段转换为特定类型,比如字符串提取整数

标签: mysql