mysql常用
1.查询行号
SELECT @rowno:=@rowno+1 as rowno,t.* from xxx t,(select @rowno:=0) r;
参考:https://blog.csdn.net/muzizhuben/article/details/49449853
2.随机取数据
SELECT * FROM xxx WHERE ... ORDER BY RAND() LIMIT 10000;
3.ddl
查看结构 DESC `xxx`;
查看索引 SHOW INDEX FROM `xxx`;
添加索引 ALTER TABLE `xxx` ADD INDEX `idx_xxx` (`xxx`);
增加列 ALTER TABLE `xxx` ADD COLUMN `xxx` INT COMMENT 'xxx' AFTER `xxx`;
4.mysql 按 in 排序
select * from ttt where aa in (1,2,3) order by field (aa,1,2,3);
参考:https://blog.csdn.net/wwwyuanliang10000/article/details/37660545
5.逗号分隔
SELECT GROUP_CONCAT(id) FROM aa WHERE xxx IN (21);
6.日期格式化 yyyy-MM-dd HH:mm:ss
select DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s')
---------------------------------------------------------------------------------------------------------------------------------------------------
bigint(10)和bigint(20)的区别 https://www.cnblogs.com/dragoncn/p/6594228.html