始于此, 终于斯
文章31
标签0
分类13

MySQL替换字段部分内容

UPDATE user SET avatar = REPLACE( avatar, 'http://', 'https://' ) WHERE avatar LIKE 'http://%';

MySQL查找指定条件的数据在排序后的位置

SELECT id FROM (SELECT uid, score, (@rowno:=@rowno+1) as rowno from user, (SELECT (@rowno:=0)) b ORDER BY score DESC) c WHERE rowno=1;

MySQL长字符字段开索引

在超长字段上创建索引时, 会报错:

ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.

在my.ini中设置 innodb_large_prefix = 1

执行下面命令, 变更数据格式

alter table <表名> row_format=dynamic;
alter table <表名> row_format=compressed;

如果报错:

South migrate error, InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope

在my.ini中设置 innodb_file_format = Barracuda 再执行上述SQL

参考: https://stackoverflow.com/questions/23556926/south-migrate-error-innodb-row-format-dynamic-requires-innodb-file-format-an
https://help.aliyun.com/knowledge_detail/155946.html