1. SQL 篇
1. 根据一个spbh字段分组, 然后取分组后每个spbh的created最新值
select * from (
select * from t_user having 1 ORDER BY created desc
) a GROUP BY spbh
2. 时间戳格式化
SELECT FROM_UNIXTIME(create_time / 1000, '%Y-%m-%d') as createTime
3. 查看当前mysql连接下,每个库的总大小
select TABLE_SCHEMA,
concat(truncate(sum(data_length) / 1024 / 1024 / 1024, 2), 'GB') as data_size,
concat(truncate(sum(index_length) / 1024 / 1024, 2), 'MB') as index_size
from information_schema.tables
group by TABLE_SCHEMA
order by data_length desc;
4.修改 tp 数据库的名称,查看当前数据库下,每个表的总大小
select TABLE_NAME,
concat(truncate(data_length / 1024 / 1024 / 1024, 2), 'GB') as data_size,
concat(truncate(index_length / 1024 / 1024 / 1024, 2), 'GB') as index_size
from information_schema.tables
where TABLE_SCHEMA = 'tp'
group by TABLE_NAME
order by data_length desc;
2. Mybaties篇
1. Mybaties,字符串Foreach循环遍历
<foreach collection="region.split(',')" open="(" separator="," close=")" item="regionParam" index="index">
#{regionParam}
</foreach>
2. 大于小于的书写
create_time <![CDATA[ <= ]]> #{endTime}
3. 模糊查询的书写
device_name like concat('%',#{deviceName},'%')
标签:语句,1024,常用,length,SQL,TABLE,data,concat,size
From: https://www.cnblogs.com/itcastwzp/p/16828566.html