获取MySQL中变量的类型 [英] Get the type of a variable in MySQL

查看:61
本文介绍了获取MySQL中变量的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我定义一个像set @a = "1";这样的变量.我怎么能看到@a是一个字符串?

If I define a variable like set @a = "1";. How can I see that @a is a string?

推荐答案

您无法在MySQL中确定变量的类型.

You cannot determine the type of a variable in MySQL.

作为替代方案,您可以轻松地将CAST()变量设置为所需的类型:

As an alternative, you can easily CAST() your variable in the type you desire:

@a = CAST(123 AS CHAR);

MySQL手册中有关强制转换的更多信息和示例:

More information and examples about casting in the MySQL Manual:

11.9.强制转换函数和运算符

这篇关于获取MySQL中变量的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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