mysql中怎么知道当前是用哪个数据库?
时间:2011-12-02
来源:互联网
问题的背景是:
1。要循环检查多个数据库(数目不定),如果出错了,要提示相应的数据库的名字,但是函数调用有很多层,不想每层都传数据库名。
mysql有没有系统变量,表示当前的数据库名?怎么在程序中得到?开发环境是VS2003 MFC 开发。
1。要循环检查多个数据库(数目不定),如果出错了,要提示相应的数据库的名字,但是函数调用有很多层,不想每层都传数据库名。
mysql有没有系统变量,表示当前的数据库名?怎么在程序中得到?开发环境是VS2003 MFC 开发。
作者: qwlong007 发布时间: 2011-12-02
DATABASE()
mysql> SELECT DATABASE();
-> 'test'
DATABASE()
返回使用 utf8 字符集的默认(当前)数据库名。在存储程序里,默认数据库是同该程序向关联的数据库,但并不一定与调用语境的默认数据库相同。
mysql> SELECT DATABASE();
-> 'test'
若没有默认数据库, DATABASE()返回 NULL。
mysql> SELECT DATABASE();
-> 'test'
DATABASE()
返回使用 utf8 字符集的默认(当前)数据库名。在存储程序里,默认数据库是同该程序向关联的数据库,但并不一定与调用语境的默认数据库相同。
mysql> SELECT DATABASE();
-> 'test'
若没有默认数据库, DATABASE()返回 NULL。
作者: ACMAIN_CHM 发布时间: 2011-12-02
DATABASE()
Returns the default (current) database name as a string in the utf8 character set. If there is no default database, DATABASE() returns NULL. Within a stored routine, the default database is the database that the routine is associated with, which is not necessarily the same as the database that is the default in the calling context.
mysql> SELECT DATABASE();
-> 'test'
If there is no default database, DATABASE() returns NULL.
Returns the default (current) database name as a string in the utf8 character set. If there is no default database, DATABASE() returns NULL. Within a stored routine, the default database is the database that the routine is associated with, which is not necessarily the same as the database that is the default in the calling context.
mysql> SELECT DATABASE();
-> 'test'
If there is no default database, DATABASE() returns NULL.
作者: wwwwb 发布时间: 2011-12-02
使用DATABASE(),可以返回当前数据库名称。如果没有打开数据库则返回null。
作者: xasinger 发布时间: 2011-12-02
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28