1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| START TRANSACTION;
-- ======================
-- Base de Données `base`
-- ======================
DROP DATABASE IF EXISTS `base`;
CREATE DATABASE `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`;
use `base`;
-- ==================
-- Procedure `verify`
-- ==================
DROP PROCEDURE IF EXISTS `verify`;
DELIMITER $$
CREATE PROCEDURE `verify` ( in_database varchar(255))
DETERMINISTIC
NO SQL
BEGIN
DECLARE _tab VARCHAR(255);
DECLARE _col VARCHAR(255);
DECLARE _line VARCHAR(255);
DECLARE _fin INTEGER DEFAULT 1;
DECLARE _curs CURSOR FOR SELECT table_name, column_name from information_schema.columns
where table_schema = in_database and data_type in ('char','varchar','text','mediumtext','longtext');
DECLARE CONTINUE HANDLER FOR NOT FOUND SET _fin = 0;
OPEN _curs;
FETCH _curs INTO _tab, _col;
WHILE (_fin)
DO
SET _line = concat('select ', _col, ' from ', in_database, '.', _tab, ' where locate(\'alphabetic\', ', _col, ') <> 0;');
SELECT _line as Requête;
SET @req = _line;
PREPARE stmt FROM @req;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
FETCH _curs INTO _tab, _col;
END WHILE;
CLOSE _curs;
END$$
DELIMITER ;
-- =====================
-- Exécuter la procédure
-- =====================
call `verify` ('mysql');
-- ===
-- Fin
-- ===
COMMIT;
EXIT |
Partager