发布时间:2021-09-02编辑:佚名阅读(2596)
DROP TABLE IF EXISTS temp; CREATE TABLE temp (tablename VARCHAR(255),LieName VARCHAR(255)); delimiter $$ DROP PROCEDURE IF EXISTS getDataByDbName $$ CREATE PROCEDURE getDataByDbName (IN dbName VARCHAR(255),IN ziduan VARCHAR (255)) BEGIN DECLARE num INT; SET @STMT = CONCAT( "SELECT COUNT(*) FROM ", dbName, " WHERE `", ziduan, "` LIKE BINARY '%特定值%' INTO @num;" ); PREPARE STMT FROM @STMT; EXECUTE STMT; IF( @num > 0 ) THEN INSERT INTO temp VALUES(dbName, ziduan); END IF; END$$ delimiter; delimiter $$ DROP PROCEDURE IF EXISTS processquanjusou$$ CREATE PROCEDURE processquanjusou() BEGIN DECLARE done BOOLEAN DEFAULT 0; DECLARE biao VARCHAR (255); DECLARE ziduan VARCHAR (255); DECLARE indexss CURSOR FOR SELECT TABLE_NAME,COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '数据库名'; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN indexss; REPEAT FETCH indexss INTO biao,ziduan; CALL getDataByDbName (biao, ziduan); UNTIL done END REPEAT; CLOSE indexss; END$$ delimiter; CALL processquanjusou (); SELECT * FROM temp;
0人
0人
0人
0人