数据库获取当前数据库名称 [英] DB get Current DB Name

查看:65
本文介绍了数据库获取当前数据库名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在DB2中编写一个SQL脚本,并且必须进行约束才能使该SQL仅在某些特定的DB上运行.

I need to write a SQL Script in DB2 and I have to make a constraint in order for this SQL to run only on some specific DBs.

我在网上寻找解决方案,但没有找到任何解决方法.

I looked online for solutions but I did not find any.

有人知道获取当前连接的数据库名称的方法吗?

Does anybody know a way to get the name of the current connected DB?

推荐答案

尝试一下:

Select CURRENT_SERVER from sysibm.sysdummy1

可以通过特殊寄存器 CURRENT_SERVER 检索数据库名称.

The database name can be retrieved via the special register CURRENT_SERVER.

这篇关于数据库获取当前数据库名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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