如何在存储过程中插入information_schema

时间:2014-12-11 08:58:33

标签: mysql stored-procedures

对于存储的操作来说,我很新。任何人都可以指导我如何将以下简单的SQL查询放在存储的进程中

$tables = mysql_query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'Fogdb' AND table_name LIKE 'fdb_table_%' ");

我尝试过如下,但它的工作

DELIMITER $$

DROP PROCEDURE IF EXISTS `alter_test_1`$$

CREATE DEFINER=`Fogdb`@`10.%` PROCEDURE `alter_test_1`()
BEGIN

SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'Fogdb' AND table_name LIKE 'fdb_table_%' 

END$$

DELIMITER ;

1 个答案:

答案 0 :(得分:0)

试试这个:

create procedure test()
begin
SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'Fogdb' AND table_name LIKE 'fdb_table_%'; 
end

在你的剧本中,你忘了把&#39 ;;'在查询结束时;

现在尝试

DELIMITER $$
DROP PROCEDURE IF EXISTS `alter_test_1`$$

CREATE DEFINER=`adtracker`@`10.%` PROCEDURE `alter_test_1`()
BEGIN

SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'Fogdb' AND table_name LIKE 'fdb_table_%' ;

END$$

DELIMITER ;