mysql存储过程输出,从MySQL中的存储过程打印调试信息

本文介绍了在MySQL中进行存储过程调试的方法,包括将消息输出到stdout、创建临时表存储调试信息以及将日志写入文件。提供了四个选项,如使用SELECT语句打印评论、设置变量并显示其值、创建临时表记录信息以及通过 outfile 将日志写入文件,但需要注意 outfile 命令的安全限制。
摘要由CSDN通过智能技术生成

Is there a way in MySQL to print debugging messages to stdout, temptable or logfile? Something like:

print in SQLServer

DBMS_OUTPUT.PUT_LINE in Oracle

解决方案

Option 1: Put this in your procedure to print 'comment' to stdout when it runs.

SELECT 'Comment';

Option 2: Put this in your procedure to print a variable with it to stdout:

declare myvar INT default 0;

SET myvar = 5;

SELECT concat('myvar is ', myvar);

This prints myvar is 5 to stdout when the procedure runs.

Option 3, Create a table with one text column called tmptable, and push messages to it:

declare myvar INT default 0;

SET myvar = 5;

insert into tmptable select concat('myvar is ', myvar);

You could put the above in a stored procedure, so all you would have to write is this:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值