MySQL 判断和删除目录和表外键
程序员文章站
2024-02-11 12:28:16
...
MySQL 判断和删除索引和表外键 ---- Procedure Of Delete Index--DROP PROCEDURE IF EXISTS DEL_IDX;CREATE PROCEDURE DEL_IDX(IN P_TABLE_NAME varchar(200), IN P_IDX_NAME VARCHAR(200))BEGINDECLARE ST VARCHAR(250); SET @ST=CONCAT(' DROP INDEX ', P_I
MySQL 判断和删除索引和表外键-- -- Procedure Of Delete Index -- DROP PROCEDURE IF EXISTS DEL_IDX; CREATE PROCEDURE DEL_IDX(IN P_TABLE_NAME varchar(200), IN P_IDX_NAME VARCHAR(200)) BEGIN DECLARE ST VARCHAR(250); SET @ST=CONCAT(' DROP INDEX ', P_IDX_NAME, ' ON ', P_TABLE_NAME); SELECT count(*) INTO @CNT FROM information_schema.statistics WHERE table_name=P_TABLE_NAME and index_name=P_IDX_NAME; IF @CNT >0 THEN PREPARE stmt FROM @ST; EXECUTE stmt; END IF; END; CALL DEL_IDX('T_NAME, 'IDX_NAME'); DROP PROCEDURE IF EXISTS DEL_IDX; -- -- Procedure Of Delete FK -- DROP PROCEDURE IF EXISTS DEL_FK; CREATE PROCEDURE DEL_FK(IN P_TABLE_NAME varchar(200), IN F_K_NAME VARCHAR(200)) BEGIN DECLARE ST VARCHAR(250); SET @ST=CONCAT(' ALTER TABLE ', P_TABLE_NAME, ' DROP FOREIGN KEY ', F_K_NAME); SELECT COUNT(*) INTO @CNT FROM information_schema.key_column_usage WHERE table_name=P_TABLE_NAME and constraint_name=F_K_NAME; IF @CNT >0 THEN PREPARE stmt FROM @ST; EXECUTE stmt; END IF; END; CALL DEL_FK('T_NAM, 'FK_NAME); DROP PROCEDURE IF EXISTS DEL_FK;
?
下一篇: 浅谈php扩展imagick_PHP教程
推荐阅读
-
MySQL 判断和删除目录和表外键
-
MySql 外键约束 之CASCADE、SET NULL、RESTRICT、空等类型分析和_MySQL
-
句,mysql 建立外键 是不是主表和子表都需要是INNODB类型
-
mysql-mySql多表查询,有中间表和外键关联
-
MySQL和sqlserver中判断表是否存在语句_MySQL
-
MySQL 判断和删除目录和表外键
-
句,mysql 建立外键 是不是主表和子表都需要是INNODB类型
-
Mysql学习3――查看表结构、修改和删除数据表_MySQL
-
mysql数据表添加海量数据和删除海量数据 代码实现_MySQL
-
句,mysql 建立外键 是不是主表和子表都需要是INNODB类型