Oracle Connection URL中的默认架构 [英] Default Schema in Oracle Connection URL
问题描述
我想在Oracle Connection URL
jdbc:oracle:thin:@<server>:<port1521>:<sid>
我的示例SQL语句:
select monkey_name from animals.monkey
我需要查询没有模式前缀animals.
的数据库,即当我运行此语句时
I need to query database without schema prefix animals.
i.e. when I run this statement
select monkey_name from monkey
默认情况下将使用animals
模式.
it will use animals
schema by default.
我需要在上面的连接URL中指定什么才能获得这种效果?
What do I need to specify in connection URL above get such effect?
谢谢.
推荐答案
您不能在连接URL中放置任何内容.
You can't put anything in the connection URL.
在Oracle中,每个用户都有自己的架构(即使不包含任何对象),这也是他们的默认架构.登录/连接后,他们可以使用
In Oracle each user has their own schema (even if doesn't contain any objects) and that is their default schema. Once logged in/connected, they can change their default schema with an
ALTER SESSION SET CURRENT_SCHEMA=animals
因此,连接后,您需要执行额外的语句. 可能在用户和/或数据库上有一个登录触发器,当他们登录时将运行此触发器.我个人希望在应用程序连接时使用显式语句.
So you'd need to do the extra statement after connecting. It is possible to have a logon trigger on the user and/or database that will run this when they log in. I'd personally prefer an explicit statement when an application connects.
这篇关于Oracle Connection URL中的默认架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!