Oracle 连接 URL 中的默认架构

2023-09-19数据库问题
11

本文介绍了Oracle 连接 URL 中的默认架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想在 Oracle Connection URL

jdbc:oracle:thin:@<server>:<port1521>:<sid>

我的示例 SQL 语句:

My sample SQL statement:

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模式.

我需要在上面的连接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 连接 URL 中的默认架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

创建分层定义的数据集的扁平表/视图
Creating a flattened table/view of a hierarchically-defined set of data(创建分层定义的数据集的扁平表/视图)...
2024-04-16 数据库问题
4

MySQL:如何做到行级安全(如 Oracle 的 Virtual Private Database)?
MySQL: how to do row-level security (like Oracle#39;s Virtual Private Database)?(MySQL:如何做到行级安全(如 Oracle 的 Virtual Private Database)?)...
2024-04-16 数据库问题
6

强制执行具有完整性约束的“子集"关系的最佳方法是什么
What is the best way to enforce a #39;subset#39; relationship with integrity constraints(强制执行具有完整性约束的“子集关系的最佳方法是什么)...
2024-04-16 数据库问题
7

使用 oracle SQL 按分隔符位置拆分字符串
Split String by delimiter position using oracle SQL(使用 oracle SQL 按分隔符位置拆分字符串)...
2024-04-16 数据库问题
46

如何根据列的值展开Oracle查询的结果
How to unfold the results of an Oracle query based on the value of a column(如何根据列的值展开Oracle查询的结果)...
2024-04-16 数据库问题
8