gpt4 book ai didi

mysql - 如何在存储过程中插入 information_schema

转载 作者:行者123 更新时间:2023-11-29 23:19:53 24 4
gpt4 key购买 nike

伙计们,我对存储过程还很陌生。谁能指导我如何将以下简单的 sql 查询放入存储过程中

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

我尝试了如下,但它不起作用

分隔符$$

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 ;

最佳答案

试试这个:

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

在您的脚本中,您忘记添加“;”在查询结束时;

现在尝试

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 ;

关于mysql - 如何在存储过程中插入 information_schema,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27418844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com