MySQL查看数据库表容量大小
参考:
https://blog.csdn.net/fdipzone/article/details/80144166
设置 SQL 语句最大长度
vi /etc/my.cnf
[mysqld]
wait_timeout = 31536000
max_allowed_packet=16M
sql:
#设置SQL最大长度为50M
set global max_allowed_packet = 52428800;
#重启mysql
#查看是否修改成功
show variables like 'max_allowed_packet';
Select
- 查询时显示行号:
SELECT @rowno:=@rowno+1 as rowno , r.* from event_alarm r,(select @rowno:=0) t
- datetime 类型转时间戳(10位)
select unix_timestamp(create_time) from dual
5.6.26版本
新增字段:
ALTER TABLE 表名 ADD `字段名` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字段注释';
删除字段:
ALTER TABLE 表名 drop column 字段名;
设置id自动增长步长:
alter table tablename auto_increment=0
格式化时间戳:
SELECT
create_time,
FROM_UNIXTIME( create_time / 1000 ), '%Y-%m-%d %H:%i:%s') AS time,
FROM_UNIXTIME( create_time / 1000, '%k' ) + 1 AS num
FROM
t_table
合并多个查询字段相同的SQL:
UNION ALL
网友评论