如何使所有mysql警告出现致命错误? [英] How can I make fatal errors of ALL mysql warnings?

查看:75
本文介绍了如何使所有mysql警告出现致命错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将所有mysql警告升级为致命错误吗?我想避免任何数据截断(包括小数部分).

Is there any way to promote all mysql warnings to fatal errors? I'd like to avoid any data truncation (including fractional parts).

推荐答案

在某些模式下,MySQL会发出警告,而不是SQL标准所要求的错误.

In some modes, MySQL raises warnings instead of the errors that are required by the SQL Standard.

您当然想在删除重要数据时引发错误,但是当COUNT(colname)表达式在列中找到一些具有空值的行而忽略它们以进行计数时,您可能不希望引发错误(标准警告).

You certainly want to raise an error when significant data is removed, but you probably don't want an error raised when a COUNT(colname) expression finds some rows with nulls in the column and ignores them for counting purposes (a Standard warning).

随着MySQL变得更加符合标准,可能会添加不涉及数据完整性的警告.

As MySQL becomes more conformant to the Standard, warnings that do not have data integrity implications may be added.

如果仅靠更严格地遵循SQL标准的方式使用MySQL是不够的,则可以在应用程序代码中捕获不可接受的警告并添加适当的补偿措施.

If using MySQL in a mode that more closely follows the SQL Standard is not enough, you could catch the unacceptable warnings in your application code and add appropriate compensating actions.

这篇关于如何使所有mysql警告出现致命错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆