惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
L
LangChain Blog
Jina AI
Jina AI
爱范儿
爱范儿
C
Check Point Blog
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
月光博客
月光博客
GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Stack Overflow Blog
Stack Overflow Blog
V
V2EX
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
The GitHub Blog
The GitHub Blog
博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题

博客园 - 每天进步多一点

MySQL5.7实现row_number()和over()函数 C#学习相关系列之Linq用法---group和join相关用法 linq group by having 实现 常用知识-T-SQL优化 mysql窗口函数、Mysql分析函数 MySQL系列三(定位慢SQL、索引优化、SQL优化)Using filesort MySQL 内存相关参数设置 MySQL COALESCE 函数使用详解 SQL性能优化指南:如何优化MySQL多表join场景 MySQL内部临时表(Using temporary)案例详解及优化解决方法 cookie操作类(加密,获取,删除) SQL SERVER年月周日超止时间 数据抽取的常见理论方法 ETL系列-数据抽取(Extract) 常用时间sql语句 数据库运维:mysql 数据库迁移方法-mysqldump 了解MySQL中的JSON_ARRAYAGG和JSON_OBJECT函数 MySQL的IFNULL()、ISNULL()、NULLIF()函数用法说明 如何看懂explain工具信息,使用explain工具来分析索引 mysql 如何查看sql语句执行时间和效率
MySql 5.7 索引不存在则创建,存在则忽略
每天进步多一点 · 2025-12-31 · via 博客园 - 每天进步多一点
-- 定义函数,其索引名称为 tbl_name_col_name
CREATE DEFINER=`root`@`%` PROCEDURE `create_index_if_not_exists`(in tbl_name varchar(64), in col_name varchar(64))
begin
    set @idx_name =concat(tbl_name, '_', col_name);
    set @index_count = (
        select count(*)
        from information_schema.statistics
        where table_schema = database()
        and table_name = tbl_name
        and index_name = @idx_name
    );
    if @index_count = 0 then
        set @create_index_sql = concat('create index ', @idx_name, ' on ', tbl_name, ' (', col_name, ')');
        prepare stmt from @create_index_sql;
        execute stmt;
        deallocate prepare stmt;
    end if;
end
-- 使用函数
CALL create_index_if_not_exists('fsys_message', 'MESSAGE_TYPE');