drop procedure if exists Pro_DelIndex
create procedure Pro_DelIndex(in TableName varchar(32), in IndexName varchar(32))
begin
declare selSql varchar(128);
declare delSql varchar(128);
declare cnt int(4) default 0;
set selSql = concat("select count(*) into @cnt from information_schema.statistics where table_name = '", TableName,"' and index_name = '", IndexName,"'");
set delSql = concat("drop index ", IndexName, " on ", TableName);
set @sql1 = selSql;
set @sql2 = delSql;
prepare selStmt from @sql1;
execute selStmt;
if @cnt > 0 then
prepare delStmt from @sql2;
execute delStmt;
end if;
end
show index from T_SC_UserManager
call Pro_DelIndex("T_SC_UserManager","IP")
MySQL删除索引的存储过程
最新推荐文章于 2023-06-12 09:13:32 发布